Artifact
65f97677c541b7937c2aa076a6acbc09d529e811:
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 65 6e 64 69 66 0a 0a 23 69 66 6e 64 65 >.#endif..#ifnde
04e0: 66 20 4e 4f 5f 54 4c 53 31 5f 31 0a 23 20 20 69 f NO_TLS1_1.# i
04f0: 66 6e 64 65 66 20 53 53 4c 5f 4f 50 5f 4e 4f 5f fndef SSL_OP_NO_
0500: 54 4c 53 76 31 5f 31 0a 23 20 20 20 20 64 65 66 TLSv1_1.# def
0510: 69 6e 65 20 4e 4f 5f 54 4c 53 31 5f 31 0a 23 20 ine NO_TLS1_1.#
0520: 20 65 6e 64 69 66 0a 23 65 6e 64 69 66 0a 0a 23 endif.#endif..#
0530: 69 66 6e 64 65 66 20 4e 4f 5f 54 4c 53 31 5f 32 ifndef NO_TLS1_2
0540: 0a 23 20 20 69 66 6e 64 65 66 20 53 53 4c 5f 4f .# ifndef SSL_O
0550: 50 5f 4e 4f 5f 54 4c 53 76 31 5f 32 0a 23 20 20 P_NO_TLSv1_2.#
0560: 20 20 64 65 66 69 6e 65 20 4e 4f 5f 54 4c 53 31 define NO_TLS1
0570: 5f 32 0a 23 20 20 65 6e 64 69 66 0a 23 65 6e 64 _2.# endif.#end
0580: 69 66 0a 0a 23 69 66 64 65 66 20 54 43 4c 5f 53 if..#ifdef TCL_S
0590: 54 4f 52 41 47 45 5f 43 4c 41 53 53 0a 23 20 75 TORAGE_CLASS.# u
05a0: 6e 64 65 66 20 54 43 4c 5f 53 54 4f 52 41 47 45 ndef TCL_STORAGE
05b0: 5f 43 4c 41 53 53 0a 23 65 6e 64 69 66 0a 23 69 _CLASS.#endif.#i
05c0: 66 64 65 66 20 42 55 49 4c 44 5f 74 6c 73 0a 23 fdef BUILD_tls.#
05d0: 20 64 65 66 69 6e 65 20 54 43 4c 5f 53 54 4f 52 define TCL_STOR
05e0: 41 47 45 5f 43 4c 41 53 53 20 44 4c 4c 45 58 50 AGE_CLASS DLLEXP
05f0: 4f 52 54 0a 23 65 6c 73 65 0a 23 20 64 65 66 69 ORT.#else.# defi
0600: 6e 65 20 54 43 4c 5f 53 54 4f 52 41 47 45 5f 43 ne TCL_STORAGE_C
0610: 4c 41 53 53 20 44 4c 4c 49 4d 50 4f 52 54 0a 23 LASS DLLIMPORT.#
0620: 65 6e 64 69 66 0a 20 0a 23 69 66 6e 64 65 66 20 endif. .#ifndef
0630: 45 43 4f 4e 4e 41 42 4f 52 54 45 44 0a 23 64 65 ECONNABORTED.#de
0640: 66 69 6e 65 20 45 43 4f 4e 4e 41 42 4f 52 54 45 fine ECONNABORTE
0650: 44 09 31 33 30 09 2f 2a 20 53 6f 66 74 77 61 72 D.130./* Softwar
0660: 65 20 63 61 75 73 65 64 20 63 6f 6e 6e 65 63 74 e caused connect
0670: 69 6f 6e 20 61 62 6f 72 74 20 2a 2f 0a 23 65 6e ion abort */.#en
0680: 64 69 66 0a 23 69 66 6e 64 65 66 20 45 43 4f 4e dif.#ifndef ECON
0690: 4e 52 45 53 45 54 0a 23 64 65 66 69 6e 65 20 45 NRESET.#define E
06a0: 43 4f 4e 4e 52 45 53 45 54 09 31 33 31 09 2f 2a CONNRESET.131./*
06b0: 20 43 6f 6e 6e 65 63 74 69 6f 6e 20 72 65 73 65 Connection rese
06c0: 74 20 62 79 20 70 65 65 72 20 2a 2f 0a 23 65 6e t by peer */.#en
06d0: 64 69 66 0a 0a 23 69 66 64 65 66 20 54 43 4c 45 dif..#ifdef TCLE
06e0: 58 54 5f 54 43 4c 54 4c 53 5f 44 45 42 55 47 0a XT_TCLTLS_DEBUG.
06f0: 23 64 65 66 69 6e 65 20 64 70 72 69 6e 74 66 28 #define dprintf(
0700: 2e 2e 2e 29 20 7b 20 66 70 72 69 6e 74 66 28 73 ...) { fprintf(s
0710: 74 64 65 72 72 2c 20 22 25 73 3a 25 69 3a 22 2c tderr, "%s:%i:",
0720: 20 5f 5f 66 75 6e 63 5f 5f 2c 20 5f 5f 4c 49 4e __func__, __LIN
0730: 45 5f 5f 29 3b 20 66 70 72 69 6e 74 66 28 73 74 E__); fprintf(st
0740: 64 65 72 72 2c 20 5f 5f 56 41 5f 41 52 47 53 5f derr, __VA_ARGS_
0750: 5f 29 3b 20 66 70 72 69 6e 74 66 28 73 74 64 65 _); fprintf(stde
0760: 72 72 2c 20 22 5c 6e 22 29 3b 20 7d 0a 23 65 6c rr, "\n"); }.#el
0770: 73 65 0a 23 64 65 66 69 6e 65 20 64 70 72 69 6e se.#define dprin
0780: 74 66 28 2e 2e 2e 29 20 69 66 20 28 30 29 20 7b tf(...) if (0) {
0790: 20 66 70 72 69 6e 74 66 28 73 74 64 65 72 72 2c fprintf(stderr,
07a0: 20 5f 5f 56 41 5f 41 52 47 53 5f 5f 29 3b 20 7d __VA_ARGS__); }
07b0: 0a 23 65 6e 64 69 66 0a 0a 23 64 65 66 69 6e 65 .#endif..#define
07c0: 20 53 53 4c 5f 45 52 52 4f 52 28 73 73 6c 2c 65 SSL_ERROR(ssl,e
07d0: 72 72 29 09 5c 0a 20 20 20 20 28 28 63 68 61 72 rr).\. ((char
07e0: 2a 29 45 52 52 5f 72 65 61 73 6f 6e 5f 65 72 72 *)ERR_reason_err
07f0: 6f 72 5f 73 74 72 69 6e 67 28 28 75 6e 73 69 67 or_string((unsig
0800: 6e 65 64 20 6c 6f 6e 67 29 53 53 4c 5f 67 65 74 ned long)SSL_get
0810: 5f 65 72 72 6f 72 28 28 73 73 6c 29 2c 28 65 72 _error((ssl),(er
0820: 72 29 29 29 29 0a 2f 2a 0a 20 2a 20 4f 70 65 6e r))))./*. * Open
0830: 53 53 4c 20 42 49 4f 20 52 6f 75 74 69 6e 65 73 SSL BIO Routines
0840: 0a 20 2a 2f 0a 23 64 65 66 69 6e 65 20 42 49 4f . */.#define BIO
0850: 5f 54 59 50 45 5f 54 43 4c 09 28 31 39 7c 30 78 _TYPE_TCL.(19|0x
0860: 30 34 30 30 29 0a 0a 2f 2a 0a 20 2a 20 44 65 66 0400)../*. * Def
0870: 69 6e 65 73 20 66 6f 72 20 53 74 61 74 65 2e 66 ines for State.f
0880: 6c 61 67 73 0a 20 2a 2f 0a 23 64 65 66 69 6e 65 lags. */.#define
0890: 20 54 4c 53 5f 54 43 4c 5f 41 53 59 4e 43 09 28 TLS_TCL_ASYNC.(
08a0: 31 3c 3c 30 29 09 2f 2a 20 6e 6f 6e 2d 62 6c 6f 1<<0)./* non-blo
08b0: 63 6b 69 6e 67 20 6d 6f 64 65 20 2a 2f 0a 23 64 cking mode */.#d
08c0: 65 66 69 6e 65 20 54 4c 53 5f 54 43 4c 5f 53 45 efine TLS_TCL_SE
08d0: 52 56 45 52 09 28 31 3c 3c 31 29 09 2f 2a 20 53 RVER.(1<<1)./* S
08e0: 65 72 76 65 72 2d 53 69 64 65 20 2a 2f 0a 23 64 erver-Side */.#d
08f0: 65 66 69 6e 65 20 54 4c 53 5f 54 43 4c 5f 49 4e efine TLS_TCL_IN
0900: 49 54 09 28 31 3c 3c 32 29 09 2f 2a 20 49 6e 69 IT.(1<<2)./* Ini
0910: 74 69 61 6c 69 7a 69 6e 67 20 63 6f 6e 6e 65 63 tializing connec
0920: 74 69 6f 6e 20 2a 2f 0a 23 64 65 66 69 6e 65 20 tion */.#define
0930: 54 4c 53 5f 54 43 4c 5f 44 45 42 55 47 09 28 31 TLS_TCL_DEBUG.(1
0940: 3c 3c 33 29 09 2f 2a 20 53 68 6f 77 20 64 65 62 <<3)./* Show deb
0950: 75 67 20 74 72 61 63 69 6e 67 20 2a 2f 0a 23 64 ug tracing */.#d
0960: 65 66 69 6e 65 20 54 4c 53 5f 54 43 4c 5f 43 41 efine TLS_TCL_CA
0970: 4c 4c 42 41 43 4b 09 28 31 3c 3c 34 29 09 2f 2a LLBACK.(1<<4)./*
0980: 20 49 6e 20 61 20 63 61 6c 6c 62 61 63 6b 2c 20 In a callback,
0990: 70 72 65 76 65 6e 74 20 75 70 64 61 74 65 0a 09 prevent update..
09a0: 09 09 09 09 20 2a 20 6c 6f 6f 70 69 6e 67 20 70 .... * looping p
09b0: 72 6f 62 6c 65 6d 2e 20 5b 42 75 67 20 31 36 35 roblem. [Bug 165
09c0: 32 33 38 30 5d 20 2a 2f 0a 23 64 65 66 69 6e 65 2380] */.#define
09d0: 20 54 4c 53 5f 54 43 4c 5f 48 41 4e 44 53 48 41 TLS_TCL_HANDSHA
09e0: 4b 45 5f 46 41 49 4c 45 44 20 28 31 3c 3c 35 29 KE_FAILED (1<<5)
09f0: 20 2f 2a 20 53 65 74 20 6f 6e 20 68 61 6e 64 73 /* Set on hands
0a00: 68 61 6b 65 20 66 61 69 6c 75 72 65 73 20 61 6e hake failures an
0a10: 64 20 6f 6e 63 65 0a 20 20 20 20 20 20 20 20 20 d once.
0a20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0a30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0a40: 2a 20 73 65 74 2c 20 61 6c 6c 20 66 75 72 74 68 * set, all furth
0a50: 65 72 20 49 2f 4f 20 77 69 6c 6c 20 72 65 73 75 er I/O will resu
0a60: 6c 74 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 lt.
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 2a 20 69 6e * in
0a90: 20 45 43 4f 4e 4e 41 42 4f 52 54 45 44 20 65 72 ECONNABORTED er
0aa0: 72 6f 72 73 2e 20 2a 2f 0a 0a 23 64 65 66 69 6e rors. */..#defin
0ab0: 65 20 54 4c 53 5f 54 43 4c 5f 44 45 4c 41 59 20 e TLS_TCL_DELAY
0ac0: 28 35 29 0a 0a 2f 2a 0a 20 2a 20 54 68 69 73 20 (5)../*. * This
0ad0: 73 74 72 75 63 74 75 72 65 20 64 65 73 63 72 69 structure descri
0ae0: 62 65 73 20 74 68 65 20 70 65 72 2d 69 6e 73 74 bes the per-inst
0af0: 61 6e 63 65 20 73 74 61 74 65 0a 20 2a 20 6f 66 ance state. * of
0b00: 20 61 6e 20 73 73 6c 20 63 68 61 6e 6e 65 6c 2e an ssl channel.
0b10: 0a 20 2a 0a 20 2a 20 54 68 65 20 53 53 4c 20 70 . *. * The SSL p
0b20: 72 6f 63 65 73 73 69 6e 67 20 63 6f 6e 74 65 78 rocessing contex
0b30: 74 20 69 73 20 6d 61 69 6e 74 61 69 6e 65 64 20 t is maintained
0b40: 68 65 72 65 2c 20 69 6e 20 74 68 65 20 43 6c 69 here, in the Cli
0b50: 65 6e 74 44 61 74 61 0a 20 2a 2f 0a 74 79 70 65 entData. */.type
0b60: 64 65 66 20 73 74 72 75 63 74 20 53 74 61 74 65 def struct State
0b70: 20 7b 0a 20 20 20 20 54 63 6c 5f 43 68 61 6e 6e {. Tcl_Chann
0b80: 65 6c 20 73 65 6c 66 3b 09 2f 2a 20 74 68 69 73 el self;./* this
0b90: 20 73 6f 63 6b 65 74 20 63 68 61 6e 6e 65 6c 20 socket channel
0ba0: 2a 2f 0a 20 20 20 20 54 63 6c 5f 54 69 6d 65 72 */. Tcl_Timer
0bb0: 54 6f 6b 65 6e 20 74 69 6d 65 72 3b 0a 0a 20 20 Token timer;..
0bc0: 20 20 69 6e 74 20 66 6c 61 67 73 3b 09 09 2f 2a int flags;../*
0bd0: 20 73 65 65 20 53 74 61 74 65 2e 66 6c 61 67 73 see State.flags
0be0: 20 61 62 6f 76 65 20 20 2a 2f 0a 20 20 20 20 69 above */. i
0bf0: 6e 74 20 77 61 74 63 68 4d 61 73 6b 3b 09 2f 2a nt watchMask;./*
0c00: 20 63 75 72 72 65 6e 74 20 57 61 74 63 68 50 72 current WatchPr
0c10: 6f 63 20 6d 61 73 6b 20 2a 2f 0a 20 20 20 20 69 oc mask */. i
0c20: 6e 74 20 6d 6f 64 65 3b 09 09 2f 2a 20 63 75 72 nt mode;../* cur
0c30: 72 65 6e 74 20 6d 6f 64 65 20 6f 66 20 70 61 72 rent mode of par
0c40: 65 6e 74 20 63 68 61 6e 6e 65 6c 20 2a 2f 0a 0a ent channel */..
0c50: 20 20 20 20 54 63 6c 5f 49 6e 74 65 72 70 20 2a Tcl_Interp *
0c60: 69 6e 74 65 72 70 3b 09 2f 2a 20 69 6e 74 65 72 interp;./* inter
0c70: 70 72 65 74 65 72 20 69 6e 20 77 68 69 63 68 20 preter in which
0c80: 74 68 69 73 20 72 65 73 69 64 65 73 20 2a 2f 0a this resides */.
0c90: 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 63 61 6c Tcl_Obj *cal
0ca0: 6c 62 61 63 6b 3b 09 2f 2a 20 73 63 72 69 70 74 lback;./* script
0cb0: 20 63 61 6c 6c 65 64 20 66 6f 72 20 74 72 61 63 called for trac
0cc0: 69 6e 67 2c 20 76 65 72 69 66 79 69 6e 67 20 61 ing, verifying a
0cd0: 6e 64 20 65 72 72 6f 72 73 20 2a 2f 0a 20 20 20 nd errors */.
0ce0: 20 54 63 6c 5f 4f 62 6a 20 2a 70 61 73 73 77 6f Tcl_Obj *passwo
0cf0: 72 64 3b 09 2f 2a 20 73 63 72 69 70 74 20 63 61 rd;./* script ca
0d00: 6c 6c 65 64 20 66 6f 72 20 63 65 72 74 69 66 69 lled for certifi
0d10: 63 61 74 65 20 70 61 73 73 77 6f 72 64 20 2a 2f cate password */
0d20: 20 0a 0a 20 20 20 20 69 6e 74 20 76 66 6c 61 67 .. int vflag
0d30: 73 3b 09 09 2f 2a 20 76 65 72 69 66 79 20 66 6c s;../* verify fl
0d40: 61 67 73 20 2a 2f 0a 20 20 20 20 53 53 4c 20 2a ags */. SSL *
0d50: 73 73 6c 3b 09 09 2f 2a 20 53 74 72 75 63 74 20 ssl;../* Struct
0d60: 66 6f 72 20 53 53 4c 20 70 72 6f 63 65 73 73 69 for SSL processi
0d70: 6e 67 20 2a 2f 0a 20 20 20 20 53 53 4c 5f 43 54 ng */. SSL_CT
0d80: 58 20 2a 63 74 78 3b 09 2f 2a 20 53 53 4c 20 43 X *ctx;./* SSL C
0d90: 6f 6e 74 65 78 74 20 2a 2f 0a 20 20 20 20 42 49 ontext */. BI
0da0: 4f 20 2a 62 69 6f 3b 09 09 2f 2a 20 53 74 72 75 O *bio;../* Stru
0db0: 63 74 20 66 6f 72 20 53 53 4c 20 70 72 6f 63 65 ct for SSL proce
0dc0: 73 73 69 6e 67 20 2a 2f 0a 20 20 20 20 42 49 4f ssing */. BIO
0dd0: 20 2a 70 5f 62 69 6f 3b 09 09 2f 2a 20 50 61 72 *p_bio;../* Par
0de0: 65 6e 74 20 42 49 4f 20 28 74 68 61 74 20 69 73 ent BIO (that is
0df0: 20 6c 61 79 65 72 65 64 20 6f 6e 20 54 63 6c 5f layered on Tcl_
0e00: 43 68 61 6e 6e 65 6c 29 20 2a 2f 0a 0a 20 20 20 Channel) */..
0e10: 20 63 68 61 72 20 2a 65 72 72 3b 0a 7d 20 53 74 char *err;.} St
0e20: 61 74 65 3b 0a 0a 2f 2a 0a 20 2a 20 54 68 65 20 ate;../*. * The
0e30: 66 6f 6c 6c 6f 77 69 6e 67 20 64 65 66 69 6e 69 following defini
0e40: 74 69 6f 6e 73 20 68 61 76 65 20 74 6f 20 62 65 tions have to be
0e50: 20 75 73 61 62 6c 65 20 66 6f 72 20 38 2e 32 2e usable for 8.2.
0e60: 30 2d 38 2e 33 2e 31 20 61 6e 64 20 38 2e 33 2e 0-8.3.1 and 8.3.
0e70: 32 2b 2e 0a 20 2a 20 54 68 65 20 64 69 66 66 65 2+.. * The diffe
0e80: 72 65 6e 63 65 73 20 62 65 74 77 65 65 6e 20 74 rences between t
0e90: 68 65 73 65 20 76 65 72 73 69 6f 6e 73 3a 0a 20 hese versions:.
0ea0: 2a 0a 20 2a 20 38 2e 30 2d 38 2e 31 3a 09 54 68 *. * 8.0-8.1:.Th
0eb0: 65 72 65 20 69 73 20 6e 6f 20 73 75 70 70 6f 72 ere is no suppor
0ec0: 74 20 66 6f 72 20 74 68 65 73 65 20 69 6e 20 54 t for these in T
0ed0: 4c 53 20 31 2e 34 20 28 67 65 74 20 31 2e 33 29 LS 1.4 (get 1.3)
0ee0: 2e 20 20 54 68 69 73 0a 20 2a 09 09 77 61 73 20 . This. *..was
0ef0: 74 68 65 20 76 65 72 73 69 6f 6e 20 77 69 74 68 the version with
0f00: 20 74 68 65 20 6f 72 69 67 69 6e 61 6c 20 70 61 the original pa
0f10: 74 63 68 2e 0a 20 2a 0a 20 2a 20 38 2e 32 2e 30 tch.. *. * 8.2.0
0f20: 2d 09 43 68 61 6e 67 65 64 20 73 65 6d 61 6e 74 -.Changed semant
0f30: 69 63 73 20 66 6f 72 20 54 63 6c 5f 53 74 61 63 ics for Tcl_Stac
0f40: 6b 43 68 61 6e 6e 65 6c 20 28 54 63 6c 5f 52 65 kChannel (Tcl_Re
0f50: 70 6c 61 63 65 43 68 61 6e 6e 65 6c 29 2e 0a 20 placeChannel)..
0f60: 2a 20 38 2e 33 2e 31 3a 09 43 68 65 63 6b 20 61 * 8.3.1:.Check a
0f70: 74 20 72 75 6e 74 69 6d 65 20 74 6f 20 73 77 69 t runtime to swi
0f80: 74 63 68 20 74 68 65 20 62 65 68 61 76 69 6f 75 tch the behaviou
0f90: 72 2e 20 54 68 65 20 70 61 74 63 68 20 69 73 20 r. The patch is
0fa0: 70 61 72 74 0a 20 2a 09 09 6f 66 20 74 68 65 20 part. *..of the
0fb0: 63 6f 72 65 20 66 72 6f 6d 20 6e 6f 77 20 6f 6e core from now on
0fc0: 2e 0a 20 2a 0a 20 2a 20 38 2e 33 2e 32 2b 3a 09 .. *. * 8.3.2+:.
0fd0: 53 74 61 63 6b 65 64 20 63 68 61 6e 6e 65 6c 73 Stacked channels
0fe0: 20 72 65 77 72 69 74 74 65 6e 20 66 6f 72 20 62 rewritten for b
0ff0: 65 74 74 65 72 20 62 65 68 61 76 69 6f 75 72 20 etter behaviour
1000: 69 6e 20 73 6f 6d 65 0a 20 2a 09 09 73 69 74 75 in some. *..situ
1010: 61 74 69 6f 6e 73 20 28 63 6c 6f 73 69 6e 67 29 ations (closing)
1020: 2e 20 53 6f 6d 65 20 6e 65 77 20 41 50 49 27 73 . Some new API's
1030: 2c 20 73 65 6d 61 6e 74 69 63 20 63 68 61 6e 67 , semantic chang
1040: 65 73 2e 0a 20 2a 0a 20 2a 20 54 68 65 20 66 6f es.. *. * The fo
1050: 6c 6c 6f 77 69 6e 67 20 6d 61 67 69 63 20 77 61 llowing magic wa
1060: 73 20 61 64 61 70 74 65 64 20 66 72 6f 6d 20 54 s adapted from T
1070: 72 66 20 32 2e 31 20 28 4b 75 70 72 69 65 73 29 rf 2.1 (Kupries)
1080: 2e 0a 20 2a 2f 0a 0a 23 64 65 66 69 6e 65 20 54 .. */..#define T
1090: 4c 53 5f 43 48 41 4e 4e 45 4c 5f 56 45 52 53 49 LS_CHANNEL_VERSI
10a0: 4f 4e 5f 31 09 30 78 31 0a 23 64 65 66 69 6e 65 ON_1.0x1.#define
10b0: 20 54 4c 53 5f 43 48 41 4e 4e 45 4c 5f 56 45 52 TLS_CHANNEL_VER
10c0: 53 49 4f 4e 5f 32 09 30 78 32 0a 65 78 74 65 72 SION_2.0x2.exter
10d0: 6e 20 69 6e 74 20 63 68 61 6e 6e 65 6c 54 79 70 n int channelTyp
10e0: 65 56 65 72 73 69 6f 6e 3b 0a 0a 23 69 66 64 65 eVersion;..#ifde
10f0: 66 20 55 53 45 5f 54 43 4c 5f 53 54 55 42 53 0a f USE_TCL_STUBS.
1100: 23 69 66 6e 64 65 66 20 54 63 6c 5f 53 74 61 63 #ifndef Tcl_Stac
1110: 6b 43 68 61 6e 6e 65 6c 0a 2f 2a 0a 20 2a 20 54 kChannel./*. * T
1120: 68 65 20 63 6f 72 65 20 77 65 20 61 72 65 20 63 he core we are c
1130: 6f 6d 70 69 6c 69 6e 67 20 61 67 61 69 6e 73 74 ompiling against
1140: 20 69 73 20 6e 6f 74 20 70 61 74 63 68 65 64 2c is not patched,
1150: 20 73 6f 20 73 75 70 70 6c 79 20 74 68 65 0a 20 so supply the.
1160: 2a 20 6e 65 63 65 73 73 73 61 72 79 20 64 65 66 * necesssary def
1170: 69 6e 69 74 69 6f 6e 73 20 68 65 72 65 20 62 79 initions here by
1180: 20 6f 75 72 73 65 6c 76 65 73 2e 20 54 68 65 20 ourselves. The
1190: 66 6f 72 6d 20 63 68 6f 73 65 6e 20 66 6f 72 0a form chosen for.
11a0: 20 2a 20 74 68 65 20 70 72 6f 63 65 64 75 72 65 * the procedure
11b0: 20 6d 61 63 72 6f 73 20 28 72 65 73 65 72 76 65 macros (reserve
11c0: 64 58 58 58 29 20 77 69 6c 6c 20 6e 6f 74 69 66 dXXX) will notif
11d0: 79 20 75 73 20 69 66 20 74 68 65 20 63 6f 72 65 y us if the core
11e0: 0a 20 2a 20 64 6f 65 73 20 6e 6f 74 20 68 61 76 . * does not hav
11f0: 65 20 74 68 65 73 65 20 72 65 73 65 72 76 65 64 e these reserved
1200: 20 6c 6f 63 61 74 69 6f 6e 73 20 61 6e 79 6d 6f locations anymo
1210: 72 65 2e 0a 20 2a 0a 20 2a 20 21 21 20 53 79 6e re.. *. * !! Syn
1220: 63 68 72 6f 6e 69 7a 65 20 74 68 65 20 70 72 6f chronize the pro
1230: 63 65 64 75 72 65 20 69 6e 64 69 63 65 73 20 69 cedure indices i
1240: 6e 20 74 68 65 69 72 20 64 65 66 69 6e 69 74 69 n their definiti
1250: 6f 6e 73 20 77 69 74 68 0a 20 2a 20 20 20 20 74 ons with. * t
1260: 68 65 20 70 61 74 63 68 20 74 6f 20 74 63 6c 2e he patch to tcl.
1270: 64 65 63 6c 73 2c 20 61 73 20 74 68 65 79 20 68 decls, as they h
1280: 61 76 65 20 74 6f 20 62 65 20 74 68 65 20 73 61 ave to be the sa
1290: 6d 65 2e 0a 20 2a 2f 0a 0a 2f 2a 20 32 38 31 20 me.. */../* 281
12a0: 2a 2f 0a 74 79 70 65 64 65 66 20 54 63 6c 5f 43 */.typedef Tcl_C
12b0: 68 61 6e 6e 65 6c 20 28 74 6c 73 5f 53 74 61 63 hannel (tls_Stac
12c0: 6b 43 68 61 6e 6e 65 6c 29 20 5f 41 4e 53 49 5f kChannel) _ANSI_
12d0: 41 52 47 53 5f 28 28 54 63 6c 5f 49 6e 74 65 72 ARGS_((Tcl_Inter
12e0: 70 2a 20 69 6e 74 65 72 70 2c 0a 09 09 09 09 09 p* interp,......
12f0: 09 20 20 20 20 54 63 6c 5f 43 68 61 6e 6e 65 6c . Tcl_Channel
1300: 54 79 70 65 2a 20 74 79 70 65 50 74 72 2c 0a 09 Type* typePtr,..
1310: 09 09 09 09 09 20 20 20 20 43 6c 69 65 6e 74 44 ..... ClientD
1320: 61 74 61 20 69 6e 73 74 61 6e 63 65 44 61 74 61 ata instanceData
1330: 2c 0a 09 09 09 09 09 09 20 20 20 20 69 6e 74 20 ,....... int
1340: 6d 61 73 6b 2c 0a 09 09 09 09 09 09 20 20 20 20 mask,.......
1350: 54 63 6c 5f 43 68 61 6e 6e 65 6c 20 70 72 65 76 Tcl_Channel prev
1360: 43 68 61 6e 29 29 3b 0a 2f 2a 20 32 38 32 20 2a Chan));./* 282 *
1370: 2f 0a 74 79 70 65 64 65 66 20 76 6f 69 64 20 28 /.typedef void (
1380: 74 6c 73 5f 55 6e 73 74 61 63 6b 43 68 61 6e 6e tls_UnstackChann
1390: 65 6c 29 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 el) _ANSI_ARGS_(
13a0: 28 54 63 6c 5f 49 6e 74 65 72 70 2a 20 69 6e 74 (Tcl_Interp* int
13b0: 65 72 70 2c 0a 09 09 09 09 09 20 20 20 20 20 20 erp,......
13c0: 20 54 63 6c 5f 43 68 61 6e 6e 65 6c 20 63 68 61 Tcl_Channel cha
13d0: 6e 29 29 3b 0a 0a 23 64 65 66 69 6e 65 20 54 63 n));..#define Tc
13e0: 6c 5f 53 74 61 63 6b 43 68 61 6e 6e 65 6c 20 20 l_StackChannel
13f0: 20 20 20 28 28 74 6c 73 5f 53 74 61 63 6b 43 68 ((tls_StackCh
1400: 61 6e 6e 65 6c 2a 29 20 74 63 6c 53 74 75 62 73 annel*) tclStubs
1410: 50 74 72 2d 3e 72 65 73 65 72 76 65 64 32 38 31 Ptr->reserved281
1420: 29 0a 23 64 65 66 69 6e 65 20 54 63 6c 5f 55 6e ).#define Tcl_Un
1430: 73 74 61 63 6b 43 68 61 6e 6e 65 6c 20 28 28 74 stackChannel ((t
1440: 6c 73 5f 55 6e 73 74 61 63 6b 43 68 61 6e 6e 65 ls_UnstackChanne
1450: 6c 2a 29 20 74 63 6c 53 74 75 62 73 50 74 72 2d l*) tclStubsPtr-
1460: 3e 72 65 73 65 72 76 65 64 32 38 32 29 0a 0a 23 >reserved282)..#
1470: 65 6e 64 69 66 20 2f 2a 20 54 63 6c 5f 53 74 61 endif /* Tcl_Sta
1480: 63 6b 43 68 61 6e 6e 65 6c 20 2a 2f 0a 0a 23 69 ckChannel */..#i
1490: 66 6e 64 65 66 20 54 63 6c 5f 47 65 74 53 74 61 fndef Tcl_GetSta
14a0: 63 6b 65 64 43 68 61 6e 6e 65 6c 0a 2f 2a 0a 20 ckedChannel./*.
14b0: 2a 20 53 65 70 61 72 61 74 65 20 64 65 66 69 6e * Separate defin
14c0: 69 74 69 6f 6e 2c 20 61 76 61 69 6c 61 62 6c 65 ition, available
14d0: 20 69 6e 20 38 2e 32 2c 20 62 75 74 20 6e 6f 74 in 8.2, but not
14e0: 20 38 2e 31 20 61 6e 64 20 62 65 66 6f 72 65 20 8.1 and before
14f0: 21 0a 20 2a 2f 0a 0a 2f 2a 20 32 38 33 20 2a 2f !. */../* 283 */
1500: 0a 74 79 70 65 64 65 66 20 54 63 6c 5f 43 68 61 .typedef Tcl_Cha
1510: 6e 6e 65 6c 20 28 74 6c 73 5f 47 65 74 53 74 61 nnel (tls_GetSta
1520: 63 6b 65 64 43 68 61 6e 6e 65 6c 29 20 5f 41 4e ckedChannel) _AN
1530: 53 49 5f 41 52 47 53 5f 28 28 54 63 6c 5f 43 68 SI_ARGS_((Tcl_Ch
1540: 61 6e 6e 65 6c 20 63 68 61 6e 29 29 3b 0a 0a 23 annel chan));..#
1550: 64 65 66 69 6e 65 20 54 63 6c 5f 47 65 74 53 74 define Tcl_GetSt
1560: 61 63 6b 65 64 43 68 61 6e 6e 65 6c 20 28 28 74 ackedChannel ((t
1570: 6c 73 5f 47 65 74 53 74 61 63 6b 65 64 43 68 61 ls_GetStackedCha
1580: 6e 6e 65 6c 2a 29 20 74 63 6c 53 74 75 62 73 50 nnel*) tclStubsP
1590: 74 72 2d 3e 72 65 73 65 72 76 65 64 32 38 33 29 tr->reserved283)
15a0: 0a 0a 23 65 6e 64 69 66 20 2f 2a 20 54 63 6c 5f ..#endif /* Tcl_
15b0: 47 65 74 53 74 61 63 6b 65 64 43 68 61 6e 6e 65 GetStackedChanne
15c0: 6c 20 2a 2f 0a 0a 0a 23 69 66 6e 64 65 66 20 54 l */...#ifndef T
15d0: 43 4c 5f 43 48 41 4e 4e 45 4c 5f 56 45 52 53 49 CL_CHANNEL_VERSI
15e0: 4f 4e 5f 32 0a 2f 2a 0a 20 2a 20 43 6f 72 65 20 ON_2./*. * Core
15f0: 69 73 20 6f 6c 64 65 72 20 74 68 61 6e 20 38 2e is older than 8.
1600: 33 2e 32 2e 20 20 53 75 70 70 6c 79 20 74 68 65 3.2. Supply the
1610: 20 6d 69 73 73 69 6e 67 20 64 65 66 69 6e 69 74 missing definit
1620: 69 6f 6e 73 20 66 6f 72 0a 20 2a 20 74 68 65 20 ions for. * the
1630: 6e 65 77 20 41 50 49 27 73 20 69 6e 20 38 2e 33 new API's in 8.3
1640: 2e 32 2e 0a 20 2a 2f 0a 23 64 65 66 69 6e 65 20 .2.. */.#define
1650: 45 4d 55 4c 41 54 45 5f 43 48 41 4e 4e 45 4c 5f EMULATE_CHANNEL_
1660: 56 45 52 53 49 4f 4e 5f 32 0a 0a 74 79 70 65 64 VERSION_2..typed
1670: 65 66 20 73 74 72 75 63 74 20 54 6c 73 43 68 61 ef struct TlsCha
1680: 6e 6e 65 6c 54 79 70 65 56 65 72 73 69 6f 6e 5f nnelTypeVersion_
1690: 2a 20 54 6c 73 43 68 61 6e 6e 65 6c 54 79 70 65 * TlsChannelType
16a0: 56 65 72 73 69 6f 6e 3b 0a 23 64 65 66 69 6e 65 Version;.#define
16b0: 20 54 43 4c 5f 43 48 41 4e 4e 45 4c 5f 56 45 52 TCL_CHANNEL_VER
16c0: 53 49 4f 4e 5f 32 09 28 28 54 6c 73 43 68 61 6e SION_2.((TlsChan
16d0: 6e 65 6c 54 79 70 65 56 65 72 73 69 6f 6e 29 20 nelTypeVersion)
16e0: 30 78 32 29 0a 0a 74 79 70 65 64 65 66 20 69 6e 0x2)..typedef in
16f0: 74 20 28 54 6c 73 44 72 69 76 65 72 48 61 6e 64 t (TlsDriverHand
1700: 6c 65 72 50 72 6f 63 29 20 5f 41 4e 53 49 5f 41 lerProc) _ANSI_A
1710: 52 47 53 5f 28 28 43 6c 69 65 6e 74 44 61 74 61 RGS_((ClientData
1720: 20 69 6e 73 74 61 6e 63 65 44 61 74 61 2c 0a 09 instanceData,..
1730: 09 09 09 09 69 6e 74 20 69 6e 74 65 72 65 73 74 ....int interest
1740: 4d 61 73 6b 29 29 3b 0a 2f 2a 20 33 39 34 20 2a Mask));./* 394 *
1750: 2f 0a 74 79 70 65 64 65 66 20 69 6e 74 20 28 74 /.typedef int (t
1760: 6c 73 5f 52 65 61 64 52 61 77 29 20 20 5f 41 4e ls_ReadRaw) _AN
1770: 53 49 5f 41 52 47 53 5f 28 28 54 63 6c 5f 43 68 SI_ARGS_((Tcl_Ch
1780: 61 6e 6e 65 6c 20 63 68 61 6e 2c 20 63 68 61 72 annel chan, char
1790: 20 2a 64 73 74 2c 0a 09 09 09 09 09 69 6e 74 20 *dst,......int
17a0: 62 79 74 65 73 54 6f 52 65 61 64 29 29 3b 0a 2f bytesToRead));./
17b0: 2a 20 33 39 35 20 2a 2f 0a 74 79 70 65 64 65 66 * 395 */.typedef
17c0: 20 69 6e 74 20 28 74 6c 73 5f 57 72 69 74 65 52 int (tls_WriteR
17d0: 61 77 29 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 aw) _ANSI_ARGS_(
17e0: 28 54 63 6c 5f 43 68 61 6e 6e 65 6c 20 63 68 61 (Tcl_Channel cha
17f0: 6e 2c 20 63 68 61 72 20 2a 73 72 63 2c 0a 09 09 n, char *src,...
1800: 09 09 09 69 6e 74 20 73 72 63 4c 65 6e 29 29 3b ...int srcLen));
1810: 0a 2f 2a 20 33 39 37 20 2a 2f 0a 74 79 70 65 64 ./* 397 */.typed
1820: 65 66 20 69 6e 74 20 28 74 6c 73 5f 47 65 74 54 ef int (tls_GetT
1830: 6f 70 43 68 61 6e 6e 65 6c 29 20 5f 41 4e 53 49 opChannel) _ANSI
1840: 5f 41 52 47 53 5f 28 28 54 63 6c 5f 43 68 61 6e _ARGS_((Tcl_Chan
1850: 6e 65 6c 20 63 68 61 6e 29 29 3b 0a 0a 2f 2a 0a nel chan));../*.
1860: 20 2a 20 47 65 6e 65 72 61 74 69 6e 67 20 63 6f * Generating co
1870: 64 65 20 66 6f 72 20 61 63 63 65 73 73 69 6e 67 de for accessing
1880: 20 74 68 65 73 65 20 70 61 72 74 73 20 6f 66 20 these parts of
1890: 74 68 65 20 73 74 75 62 20 74 61 62 6c 65 20 77 the stub table w
18a0: 68 65 6e 0a 20 2a 20 63 6f 6d 70 69 6c 69 6e 67 hen. * compiling
18b0: 20 61 67 61 69 6e 73 74 20 61 20 63 6f 72 65 20 against a core
18c0: 6f 6c 64 65 72 20 74 68 61 6e 20 38 2e 33 2e 32 older than 8.3.2
18d0: 20 69 73 20 61 20 68 61 73 73 6c 65 20 62 65 63 is a hassle bec
18e0: 61 75 73 65 20 65 76 65 6e 0a 20 2a 20 74 68 65 ause even. * the
18f0: 20 27 72 65 73 65 72 76 65 64 58 58 58 27 20 66 'reservedXXX' f
1900: 69 65 6c 64 73 20 6f 66 20 74 68 65 20 73 74 72 ields of the str
1910: 75 63 74 75 72 65 20 61 72 65 20 6e 6f 74 20 64 ucture are not d
1920: 65 66 69 6e 65 64 20 79 65 74 2e 20 53 6f 0a 20 efined yet. So.
1930: 2a 20 77 65 20 68 61 76 65 20 74 6f 20 77 72 69 * we have to wri
1940: 74 65 20 75 70 20 73 6f 6d 65 20 6d 61 63 72 6f te up some macro
1950: 73 20 68 69 64 69 6e 67 20 73 6f 6d 65 20 76 65 s hiding some ve
1960: 72 79 20 68 61 63 6b 69 73 68 20 70 6f 69 6e 74 ry hackish point
1970: 65 72 0a 20 2a 20 61 72 69 74 68 6d 65 74 69 63 er. * arithmetic
1980: 73 20 74 6f 20 67 65 74 20 61 74 20 74 68 65 73 s to get at thes
1990: 65 20 66 69 65 6c 64 73 2e 20 57 65 20 61 73 73 e fields. We ass
19a0: 75 6d 65 20 74 68 61 74 20 70 6f 69 6e 74 65 72 ume that pointer
19b0: 20 74 6f 0a 20 2a 20 66 75 6e 63 74 69 6f 6e 73 to. * functions
19c0: 20 61 72 65 20 61 6c 77 61 79 73 20 6f 66 20 74 are always of t
19d0: 68 65 20 73 61 6d 65 20 73 69 7a 65 2e 0a 20 2a he same size.. *
19e0: 2f 0a 0a 23 64 65 66 69 6e 65 20 53 54 55 42 5f /..#define STUB_
19f0: 42 41 53 45 20 20 20 28 28 63 68 61 72 2a 29 28 BASE ((char*)(
1a00: 26 28 74 63 6c 53 74 75 62 73 50 74 72 2d 3e 74 &(tclStubsPtr->t
1a10: 63 6c 5f 55 74 66 4e 63 61 73 65 63 6d 70 29 29 cl_UtfNcasecmp))
1a20: 29 20 2f 2a 20 66 69 65 6c 64 20 33 37 30 20 2a ) /* field 370 *
1a30: 2f 0a 23 64 65 66 69 6e 65 20 70 72 6f 63 50 74 /.#define procPt
1a40: 72 53 69 7a 65 20 28 73 69 7a 65 6f 66 20 28 54 rSize (sizeof (T
1a50: 63 6c 5f 44 72 69 76 65 72 42 6c 6f 63 6b 4d 6f cl_DriverBlockMo
1a60: 64 65 50 72 6f 63 20 2a 29 29 0a 23 64 65 66 69 deProc *)).#defi
1a70: 6e 65 20 49 44 58 28 6e 29 20 20 20 20 20 20 28 ne IDX(n) (
1a80: 28 28 6e 29 2d 33 37 30 29 20 2a 20 70 72 6f 63 ((n)-370) * proc
1a90: 50 74 72 53 69 7a 65 29 0a 23 64 65 66 69 6e 65 PtrSize).#define
1aa0: 20 53 4c 4f 54 28 6e 29 20 20 20 20 20 28 53 54 SLOT(n) (ST
1ab0: 55 42 5f 42 41 53 45 20 2b 20 49 44 58 28 6e 29 UB_BASE + IDX(n)
1ac0: 29 0a 0a 23 64 65 66 69 6e 65 20 54 63 6c 5f 52 )..#define Tcl_R
1ad0: 65 61 64 52 61 77 09 09 28 2a 28 28 74 6c 73 5f eadRaw..(*((tls_
1ae0: 52 65 61 64 52 61 77 2a 2a 29 09 28 53 4c 4f 54 ReadRaw**).(SLOT
1af0: 28 33 39 34 29 29 29 29 0a 23 64 65 66 69 6e 65 (394)))).#define
1b00: 20 54 63 6c 5f 57 72 69 74 65 52 61 77 09 09 28 Tcl_WriteRaw..(
1b10: 2a 28 28 74 6c 73 5f 57 72 69 74 65 52 61 77 2a *((tls_WriteRaw*
1b20: 2a 29 09 28 53 4c 4f 54 28 33 39 35 29 29 29 29 *).(SLOT(395))))
1b30: 0a 23 64 65 66 69 6e 65 20 54 63 6c 5f 47 65 74 .#define Tcl_Get
1b40: 54 6f 70 43 68 61 6e 6e 65 6c 09 28 2a 28 28 74 TopChannel.(*((t
1b50: 6c 73 5f 47 65 74 54 6f 70 43 68 61 6e 6e 65 6c ls_GetTopChannel
1b60: 2a 2a 29 28 53 4c 4f 54 28 33 39 36 29 29 29 29 **)(SLOT(396))))
1b70: 0a 0a 2f 2a 0a 20 2a 20 52 65 71 75 69 72 65 64 ../*. * Required
1b80: 2c 20 65 61 73 79 20 65 6d 75 6c 61 74 69 6f 6e , easy emulation
1b90: 2e 0a 20 2a 2f 0a 23 64 65 66 69 6e 65 20 54 63 .. */.#define Tc
1ba0: 6c 5f 43 68 61 6e 6e 65 6c 47 65 74 4f 70 74 69 l_ChannelGetOpti
1bb0: 6f 6e 50 72 6f 63 28 63 68 61 6e 44 72 69 76 65 onProc(chanDrive
1bc0: 72 29 20 28 28 63 68 61 6e 44 72 69 76 65 72 29 r) ((chanDriver)
1bd0: 2d 3e 67 65 74 4f 70 74 69 6f 6e 50 72 6f 63 29 ->getOptionProc)
1be0: 0a 0a 23 65 6e 64 69 66 20 2f 2a 20 54 43 4c 5f ..#endif /* TCL_
1bf0: 43 48 41 4e 4e 45 4c 5f 56 45 52 53 49 4f 4e 5f CHANNEL_VERSION_
1c00: 32 20 2a 2f 0a 0a 23 65 6e 64 69 66 20 2f 2a 20 2 */..#endif /*
1c10: 55 53 45 5f 54 43 4c 5f 53 54 55 42 53 20 2a 2f USE_TCL_STUBS */
1c20: 0a 0a 2f 2a 0a 20 2a 20 46 6f 72 77 61 72 64 20 ../*. * Forward
1c30: 64 65 63 6c 61 72 61 74 69 6f 6e 73 0a 20 2a 2f declarations. */
1c40: 0a 0a 54 63 6c 5f 43 68 61 6e 6e 65 6c 54 79 70 ..Tcl_ChannelTyp
1c50: 65 20 2a 54 6c 73 5f 43 68 61 6e 6e 65 6c 54 79 e *Tls_ChannelTy
1c60: 70 65 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 pe _ANSI_ARGS_((
1c70: 76 6f 69 64 29 29 3b 0a 54 63 6c 5f 43 68 61 6e void));.Tcl_Chan
1c80: 6e 65 6c 09 54 6c 73 5f 47 65 74 50 61 72 65 6e nel.Tls_GetParen
1c90: 74 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 53 t _ANSI_ARGS_((S
1ca0: 74 61 74 65 20 2a 73 74 61 74 65 50 74 72 29 29 tate *statePtr))
1cb0: 3b 0a 0a 54 63 6c 5f 4f 62 6a 2a 09 09 54 6c 73 ;..Tcl_Obj*..Tls
1cc0: 5f 4e 65 77 58 35 30 39 4f 62 6a 20 5f 41 4e 53 _NewX509Obj _ANS
1cd0: 49 5f 41 52 47 53 5f 20 28 28 20 54 63 6c 5f 49 I_ARGS_ (( Tcl_I
1ce0: 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 2c 20 58 nterp *interp, X
1cf0: 35 30 39 20 2a 63 65 72 74 29 29 3b 0a 76 6f 69 509 *cert));.voi
1d00: 64 09 09 54 6c 73 5f 45 72 72 6f 72 20 5f 41 4e d..Tls_Error _AN
1d10: 53 49 5f 41 52 47 53 5f 20 28 28 53 74 61 74 65 SI_ARGS_ ((State
1d20: 20 2a 73 74 61 74 65 50 74 72 2c 20 63 68 61 72 *statePtr, char
1d30: 20 2a 6d 73 67 29 29 3b 0a 76 6f 69 64 09 09 54 *msg));.void..T
1d40: 6c 73 5f 46 72 65 65 20 5f 41 4e 53 49 5f 41 52 ls_Free _ANSI_AR
1d50: 47 53 5f 20 28 28 63 68 61 72 20 2a 62 6c 6f 63 GS_ ((char *bloc
1d60: 6b 50 74 72 29 29 3b 0a 76 6f 69 64 09 09 54 6c kPtr));.void..Tl
1d70: 73 5f 43 6c 65 61 6e 20 5f 41 4e 53 49 5f 41 52 s_Clean _ANSI_AR
1d80: 47 53 5f 20 28 28 53 74 61 74 65 20 2a 73 74 61 GS_ ((State *sta
1d90: 74 65 50 74 72 29 29 3b 0a 69 6e 74 09 09 54 6c tePtr));.int..Tl
1da0: 73 5f 57 61 69 74 46 6f 72 43 6f 6e 6e 65 63 74 s_WaitForConnect
1db0: 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 20 53 _ANSI_ARGS_(( S
1dc0: 74 61 74 65 20 2a 73 74 61 74 65 50 74 72 2c 0a tate *statePtr,.
1dd0: 09 09 09 09 09 09 09 69 6e 74 20 2a 65 72 72 6f .......int *erro
1de0: 72 43 6f 64 65 50 74 72 29 29 3b 0a 0a 42 49 4f rCodePtr));..BIO
1df0: 20 2a 09 09 42 49 4f 5f 6e 65 77 5f 74 63 6c 20 *..BIO_new_tcl
1e00: 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 53 74 61 _ANSI_ARGS_((Sta
1e10: 74 65 2a 20 73 74 61 74 65 50 74 72 2c 20 69 6e te* statePtr, in
1e20: 74 20 66 6c 61 67 73 29 29 3b 0a 0a 23 65 6e 64 t flags));..#end
1e30: 69 66 20 2f 2a 20 5f 54 4c 53 49 4e 54 5f 48 20 if /* _TLSINT_H
1e40: 2a 2f 0a */.