Artifact
aca790a765f221eca657d6b0d7971ba161592b01 :
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 24 48 65 61 64 65 72 3a 20 2f 68 6f . * $Header: /ho
0050: 6d 65 2f 72 6b 65 65 6e 65 2f 74 6d 70 2f 63 76 me/rkeene/tmp/cv
0060: 73 32 66 6f 73 73 69 6c 2f 2e 2e 2f 74 63 6c 74 s2fossil/../tclt
0070: 6c 73 2f 74 6c 73 2f 74 6c 73 2f 74 6c 73 49 6e ls/tls/tls/tlsIn
0080: 74 2e 68 2c 76 20 31 2e 31 37 20 32 30 31 35 2f t.h,v 1.17 2015/
0090: 30 36 2f 30 36 20 30 39 3a 30 37 3a 30 38 20 61 06/06 09:07:08 a
00a0: 70 6e 61 64 6b 61 72 6e 69 20 45 78 70 20 24 0a pnadkarni Exp $.
00b0: 20 2a 0a 20 2a 20 54 4c 53 20 28 61 6b 61 20 53 *. * TLS (aka S
00c0: 53 4c 29 20 43 68 61 6e 6e 65 6c 20 2d 20 63 61 SL) Channel - ca
00d0: 6e 20 62 65 20 6c 61 79 65 72 65 64 20 6f 6e 20 n be layered on
00e0: 61 6e 79 20 62 69 2d 64 69 72 65 63 74 69 6f 6e any bi-direction
00f0: 61 6c 0a 20 2a 20 54 63 6c 5f 43 68 61 6e 6e 65 al. * Tcl_Channe
0100: 6c 20 28 4e 6f 74 65 3a 20 52 65 71 75 69 72 65 l (Note: Require
0110: 73 20 54 72 66 20 43 6f 72 65 20 50 61 74 63 68 s Trf Core Patch
0120: 29 0a 20 2a 0a 20 2a 20 54 68 69 73 20 77 61 73 ). *. * This was
0130: 20 62 75 69 6c 74 20 66 72 6f 6d 20 73 63 72 61 built from scra
0140: 74 63 68 20 62 61 73 65 64 20 75 70 6f 6e 20 6f tch based upon o
0150: 62 73 65 72 76 61 74 69 6f 6e 20 6f 66 20 4f 70 bservation of Op
0160: 65 6e 53 53 4c 20 30 2e 39 2e 32 42 0a 20 2a 0a enSSL 0.9.2B. *.
0170: 20 2a 20 41 64 64 69 74 69 6f 6e 20 63 72 65 64 * Addition cred
0180: 69 74 20 69 73 20 64 75 65 20 66 6f 72 20 41 6e it is due for An
0190: 64 72 65 61 73 20 4b 75 70 72 69 65 73 20 28 61 dreas Kupries (a
01a0: 2e 6b 75 70 72 69 65 73 40 77 65 73 74 65 6e 64 .kupries@westend
01b0: 2e 63 6f 6d 29 2c 20 66 6f 72 0a 20 2a 20 70 72 .com), for. * pr
01c0: 6f 76 69 64 69 6e 67 20 74 68 65 20 54 63 6c 5f oviding the Tcl_
01d0: 52 65 70 6c 61 63 65 43 68 61 6e 6e 65 6c 20 6d ReplaceChannel m
01e0: 65 63 68 61 6e 69 73 6d 20 61 6e 64 20 77 6f 72 echanism and wor
01f0: 6b 69 6e 67 20 63 6c 6f 73 65 6c 79 20 77 69 74 king closely wit
0200: 68 20 6d 65 0a 20 2a 20 74 6f 20 65 6e 68 61 6e h me. * to enhan
0210: 63 65 20 69 74 20 74 6f 20 73 75 70 70 6f 72 74 ce it to support
0220: 20 66 75 6c 6c 20 66 69 6c 65 65 76 65 6e 74 20 full fileevent
0230: 73 65 6d 61 6e 74 69 63 73 2e 0a 20 2a 0a 20 2a semantics.. *. *
0240: 20 41 6c 73 6f 20 77 6f 72 6b 20 64 6f 6e 65 20 Also work done
0250: 62 79 20 74 68 65 20 66 6f 6c 6c 6f 77 20 70 65 by the follow pe
0260: 6f 70 6c 65 20 70 72 6f 76 69 64 65 64 20 74 68 ople provided th
0270: 65 20 69 6d 70 65 74 75 73 20 74 6f 20 64 6f 20 e impetus to do
0280: 74 68 69 73 20 22 72 69 67 68 74 22 3a 2d 0a 20 this "right":-.
0290: 2a 09 74 63 6c 53 53 4c 20 28 43 6f 6c 69 6e 20 *.tclSSL (Colin
02a0: 4d 63 43 6f 72 6d 61 63 6b 2c 20 53 68 61 72 65 McCormack, Share
02b0: 64 20 54 65 63 68 6e 6f 6c 6f 67 79 29 0a 20 2a d Technology). *
02c0: 09 53 53 4c 74 63 6c 20 28 50 65 74 65 72 20 41 .SSLtcl (Peter A
02d0: 6e 74 6d 61 6e 29 0a 20 2a 0a 20 2a 2f 0a 23 69 ntman). *. */.#i
02e0: 66 6e 64 65 66 20 5f 54 53 4c 49 4e 54 5f 48 0a fndef _TSLINT_H.
02f0: 23 64 65 66 69 6e 65 20 5f 54 4c 53 49 4e 54 5f #define _TLSINT_
0300: 48 0a 0a 23 69 6e 63 6c 75 64 65 20 22 74 6c 73 H..#include "tls
0310: 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20 3c 65 72 .h".#include <er
0320: 72 6e 6f 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 rno.h>.#include
0330: 3c 73 74 72 69 6e 67 2e 68 3e 0a 0a 23 69 66 64 <string.h>..#ifd
0340: 65 66 20 5f 5f 57 49 4e 33 32 5f 5f 0a 23 64 65 ef __WIN32__.#de
0350: 66 69 6e 65 20 57 49 4e 33 32 5f 4c 45 41 4e 5f fine WIN32_LEAN_
0360: 41 4e 44 5f 4d 45 41 4e 0a 23 69 6e 63 6c 75 64 AND_MEAN.#includ
0370: 65 20 3c 77 69 6e 64 6f 77 73 2e 68 3e 0a 23 69 e <windows.h>.#i
0380: 6e 63 6c 75 64 65 20 3c 77 69 6e 63 72 79 70 74 nclude <wincrypt
0390: 2e 68 3e 20 2f 2a 20 4f 70 65 6e 53 53 4c 20 6e .h> /* OpenSSL n
03a0: 65 65 64 73 20 74 68 69 73 20 6f 6e 20 57 69 6e eeds this on Win
03b0: 64 6f 77 73 20 2a 2f 0a 23 65 6e 64 69 66 0a 0a dows */.#endif..
03c0: 2f 2a 20 48 61 6e 64 6c 65 20 74 63 6c 38 2e 33 /* Handle tcl8.3
03d0: 2d 3e 74 63 6c 38 2e 34 20 43 4f 4e 53 54 20 63 ->tcl8.4 CONST c
03e0: 68 61 6e 67 65 73 20 2a 2f 0a 23 69 66 6e 64 65 hanges */.#ifnde
03f0: 66 20 43 4f 4e 53 54 38 34 0a 23 64 65 66 69 6e f CONST84.#defin
0400: 65 20 43 4f 4e 53 54 38 34 0a 23 65 6e 64 69 66 e CONST84.#endif
0410: 0a 0a 23 69 66 64 65 66 20 4e 4f 5f 50 41 54 45 ..#ifdef NO_PATE
0420: 4e 54 53 0a 23 64 65 66 69 6e 65 20 4e 4f 5f 49 NTS.#define NO_I
0430: 44 45 41 0a 23 64 65 66 69 6e 65 20 4e 4f 5f 52 DEA.#define NO_R
0440: 43 32 0a 23 64 65 66 69 6e 65 20 4e 4f 5f 52 43 C2.#define NO_RC
0450: 34 0a 23 64 65 66 69 6e 65 20 4e 4f 5f 52 43 35 4.#define NO_RC5
0460: 0a 23 64 65 66 69 6e 65 20 4e 4f 5f 52 53 41 0a .#define NO_RSA.
0470: 23 64 65 66 69 6e 65 20 4e 4f 5f 53 53 4c 32 0a #define NO_SSL2.
0480: 23 65 6e 64 69 66 0a 0a 23 69 66 64 65 66 20 42 #endif..#ifdef B
0490: 53 41 46 45 0a 23 69 6e 63 6c 75 64 65 20 3c 73 SAFE.#include <s
04a0: 73 6c 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c sl.h>.#include <
04b0: 65 72 72 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 err.h>.#include
04c0: 3c 72 61 6e 64 2e 68 3e 0a 23 65 6c 73 65 0a 23 <rand.h>.#else.#
04d0: 69 6e 63 6c 75 64 65 20 3c 6f 70 65 6e 73 73 6c include <openssl
04e0: 2f 73 73 6c 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 /ssl.h>.#include
04f0: 20 3c 6f 70 65 6e 73 73 6c 2f 65 72 72 2e 68 3e <openssl/err.h>
0500: 0a 23 69 6e 63 6c 75 64 65 20 3c 6f 70 65 6e 73 .#include <opens
0510: 73 6c 2f 72 61 6e 64 2e 68 3e 0a 23 65 6e 64 69 sl/rand.h>.#endi
0520: 66 0a 0a 23 69 66 6e 64 65 66 20 53 53 4c 5f 4f f..#ifndef SSL_O
0530: 50 5f 4e 4f 5f 54 4c 53 76 31 5f 31 0a 23 64 65 P_NO_TLSv1_1.#de
0540: 66 69 6e 65 20 4e 4f 5f 54 4c 53 31 5f 31 0a 23 fine NO_TLS1_1.#
0550: 65 6e 64 69 66 0a 0a 23 69 66 6e 64 65 66 20 53 endif..#ifndef S
0560: 53 4c 5f 4f 50 5f 4e 4f 5f 54 4c 53 76 31 5f 32 SL_OP_NO_TLSv1_2
0570: 0a 23 64 65 66 69 6e 65 20 4e 4f 5f 54 4c 53 31 .#define NO_TLS1
0580: 5f 32 0a 23 65 6e 64 69 66 0a 0a 23 69 66 64 65 _2.#endif..#ifde
0590: 66 20 54 43 4c 5f 53 54 4f 52 41 47 45 5f 43 4c f TCL_STORAGE_CL
05a0: 41 53 53 0a 23 20 75 6e 64 65 66 20 54 43 4c 5f ASS.# undef TCL_
05b0: 53 54 4f 52 41 47 45 5f 43 4c 41 53 53 0a 23 65 STORAGE_CLASS.#e
05c0: 6e 64 69 66 0a 23 69 66 64 65 66 20 42 55 49 4c ndif.#ifdef BUIL
05d0: 44 5f 74 6c 73 0a 23 20 64 65 66 69 6e 65 20 54 D_tls.# define T
05e0: 43 4c 5f 53 54 4f 52 41 47 45 5f 43 4c 41 53 53 CL_STORAGE_CLASS
05f0: 20 44 4c 4c 45 58 50 4f 52 54 0a 23 65 6c 73 65 DLLEXPORT.#else
0600: 0a 23 20 64 65 66 69 6e 65 20 54 43 4c 5f 53 54 .# define TCL_ST
0610: 4f 52 41 47 45 5f 43 4c 41 53 53 20 44 4c 4c 49 ORAGE_CLASS DLLI
0620: 4d 50 4f 52 54 0a 23 65 6e 64 69 66 0a 20 0a 23 MPORT.#endif. .#
0630: 69 66 6e 64 65 66 20 45 43 4f 4e 4e 41 42 4f 52 ifndef ECONNABOR
0640: 54 45 44 0a 23 64 65 66 69 6e 65 20 45 43 4f 4e TED.#define ECON
0650: 4e 41 42 4f 52 54 45 44 09 31 33 30 09 2f 2a 20 NABORTED.130./*
0660: 53 6f 66 74 77 61 72 65 20 63 61 75 73 65 64 20 Software caused
0670: 63 6f 6e 6e 65 63 74 69 6f 6e 20 61 62 6f 72 74 connection abort
0680: 20 2a 2f 0a 23 65 6e 64 69 66 0a 23 69 66 6e 64 */.#endif.#ifnd
0690: 65 66 20 45 43 4f 4e 4e 52 45 53 45 54 0a 23 64 ef ECONNRESET.#d
06a0: 65 66 69 6e 65 20 45 43 4f 4e 4e 52 45 53 45 54 efine ECONNRESET
06b0: 09 31 33 31 09 2f 2a 20 43 6f 6e 6e 65 63 74 69 .131./* Connecti
06c0: 6f 6e 20 72 65 73 65 74 20 62 79 20 70 65 65 72 on reset by peer
06d0: 20 2a 2f 0a 23 65 6e 64 69 66 0a 0a 23 69 66 64 */.#endif..#ifd
06e0: 65 66 20 44 45 42 55 47 0a 23 64 65 66 69 6e 65 ef DEBUG.#define
06f0: 20 64 70 72 69 6e 74 66 20 66 70 72 69 6e 74 66 dprintf fprintf
0700: 0a 23 65 6c 73 65 0a 23 64 65 66 69 6e 65 20 64 .#else.#define d
0710: 70 72 69 6e 74 66 20 69 66 20 28 30 29 20 66 70 printf if (0) fp
0720: 72 69 6e 74 66 0a 23 65 6e 64 69 66 0a 0a 23 64 rintf.#endif..#d
0730: 65 66 69 6e 65 20 53 53 4c 5f 45 52 52 4f 52 28 efine SSL_ERROR(
0740: 73 73 6c 2c 65 72 72 29 09 5c 0a 20 20 20 20 28 ssl,err).\. (
0750: 28 63 68 61 72 2a 29 45 52 52 5f 72 65 61 73 6f (char*)ERR_reaso
0760: 6e 5f 65 72 72 6f 72 5f 73 74 72 69 6e 67 28 28 n_error_string((
0770: 75 6e 73 69 67 6e 65 64 20 6c 6f 6e 67 29 53 53 unsigned long)SS
0780: 4c 5f 67 65 74 5f 65 72 72 6f 72 28 28 73 73 6c L_get_error((ssl
0790: 29 2c 28 65 72 72 29 29 29 29 0a 2f 2a 0a 20 2a ),(err))))./*. *
07a0: 20 4f 70 65 6e 53 53 4c 20 42 49 4f 20 52 6f 75 OpenSSL BIO Rou
07b0: 74 69 6e 65 73 0a 20 2a 2f 0a 23 64 65 66 69 6e tines. */.#defin
07c0: 65 20 42 49 4f 5f 54 59 50 45 5f 54 43 4c 09 28 e BIO_TYPE_TCL.(
07d0: 31 39 7c 30 78 30 34 30 30 29 0a 0a 2f 2a 0a 20 19|0x0400)../*.
07e0: 2a 20 44 65 66 69 6e 65 73 20 66 6f 72 20 53 74 * Defines for St
07f0: 61 74 65 2e 66 6c 61 67 73 0a 20 2a 2f 0a 23 64 ate.flags. */.#d
0800: 65 66 69 6e 65 20 54 4c 53 5f 54 43 4c 5f 41 53 efine TLS_TCL_AS
0810: 59 4e 43 09 28 31 3c 3c 30 29 09 2f 2a 20 6e 6f YNC.(1<<0)./* no
0820: 6e 2d 62 6c 6f 63 6b 69 6e 67 20 6d 6f 64 65 20 n-blocking mode
0830: 2a 2f 0a 23 64 65 66 69 6e 65 20 54 4c 53 5f 54 */.#define TLS_T
0840: 43 4c 5f 53 45 52 56 45 52 09 28 31 3c 3c 31 29 CL_SERVER.(1<<1)
0850: 09 2f 2a 20 53 65 72 76 65 72 2d 53 69 64 65 20 ./* Server-Side
0860: 2a 2f 0a 23 64 65 66 69 6e 65 20 54 4c 53 5f 54 */.#define TLS_T
0870: 43 4c 5f 49 4e 49 54 09 28 31 3c 3c 32 29 09 2f CL_INIT.(1<<2)./
0880: 2a 20 49 6e 69 74 69 61 6c 69 7a 69 6e 67 20 63 * Initializing c
0890: 6f 6e 6e 65 63 74 69 6f 6e 20 2a 2f 0a 23 64 65 onnection */.#de
08a0: 66 69 6e 65 20 54 4c 53 5f 54 43 4c 5f 44 45 42 fine TLS_TCL_DEB
08b0: 55 47 09 28 31 3c 3c 33 29 09 2f 2a 20 53 68 6f UG.(1<<3)./* Sho
08c0: 77 20 64 65 62 75 67 20 74 72 61 63 69 6e 67 20 w debug tracing
08d0: 2a 2f 0a 23 64 65 66 69 6e 65 20 54 4c 53 5f 54 */.#define TLS_T
08e0: 43 4c 5f 43 41 4c 4c 42 41 43 4b 09 28 31 3c 3c CL_CALLBACK.(1<<
08f0: 34 29 09 2f 2a 20 49 6e 20 61 20 63 61 6c 6c 62 4)./* In a callb
0900: 61 63 6b 2c 20 70 72 65 76 65 6e 74 20 75 70 64 ack, prevent upd
0910: 61 74 65 0a 09 09 09 09 09 20 2a 20 6c 6f 6f 70 ate...... * loop
0920: 69 6e 67 20 70 72 6f 62 6c 65 6d 2e 20 5b 42 75 ing problem. [Bu
0930: 67 20 31 36 35 32 33 38 30 5d 20 2a 2f 0a 23 64 g 1652380] */.#d
0940: 65 66 69 6e 65 20 54 4c 53 5f 54 43 4c 5f 48 41 efine TLS_TCL_HA
0950: 4e 44 53 48 41 4b 45 5f 46 41 49 4c 45 44 20 28 NDSHAKE_FAILED (
0960: 31 3c 3c 35 29 20 2f 2a 20 53 65 74 20 6f 6e 20 1<<5) /* Set on
0970: 68 61 6e 64 73 68 61 6b 65 20 66 61 69 6c 75 72 handshake failur
0980: 65 73 20 61 6e 64 20 6f 6e 63 65 0a 20 20 20 20 es and once.
0990: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
09a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
09b0: 20 20 20 20 20 2a 20 73 65 74 2c 20 61 6c 6c 20 * set, all
09c0: 66 75 72 74 68 65 72 20 49 2f 4f 20 77 69 6c 6c further I/O will
09d0: 20 72 65 73 75 6c 74 0a 20 20 20 20 20 20 20 20 result.
09e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
09f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0a00: 20 2a 20 69 6e 20 45 43 4f 4e 4e 41 42 4f 52 54 * in ECONNABORT
0a10: 45 44 20 65 72 72 6f 72 73 2e 20 2a 2f 0a 0a 23 ED errors. */..#
0a20: 64 65 66 69 6e 65 20 54 4c 53 5f 54 43 4c 5f 44 define TLS_TCL_D
0a30: 45 4c 41 59 20 28 35 29 0a 0a 2f 2a 0a 20 2a 20 ELAY (5)../*. *
0a40: 54 68 69 73 20 73 74 72 75 63 74 75 72 65 20 64 This structure d
0a50: 65 73 63 72 69 62 65 73 20 74 68 65 20 70 65 72 escribes the per
0a60: 2d 69 6e 73 74 61 6e 63 65 20 73 74 61 74 65 0a -instance state.
0a70: 20 2a 20 6f 66 20 61 6e 20 73 73 6c 20 63 68 61 * of an ssl cha
0a80: 6e 6e 65 6c 2e 0a 20 2a 0a 20 2a 20 54 68 65 20 nnel.. *. * The
0a90: 53 53 4c 20 70 72 6f 63 65 73 73 69 6e 67 20 63 SSL processing c
0aa0: 6f 6e 74 65 78 74 20 69 73 20 6d 61 69 6e 74 61 ontext is mainta
0ab0: 69 6e 65 64 20 68 65 72 65 2c 20 69 6e 20 74 68 ined here, in th
0ac0: 65 20 43 6c 69 65 6e 74 44 61 74 61 0a 20 2a 2f e ClientData. */
0ad0: 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 74 20 .typedef struct
0ae0: 53 74 61 74 65 20 7b 0a 20 20 20 20 54 63 6c 5f State {. Tcl_
0af0: 43 68 61 6e 6e 65 6c 20 73 65 6c 66 3b 09 2f 2a Channel self;./*
0b00: 20 74 68 69 73 20 73 6f 63 6b 65 74 20 63 68 61 this socket cha
0b10: 6e 6e 65 6c 20 2a 2f 0a 20 20 20 20 54 63 6c 5f nnel */. Tcl_
0b20: 54 69 6d 65 72 54 6f 6b 65 6e 20 74 69 6d 65 72 TimerToken timer
0b30: 3b 0a 0a 20 20 20 20 69 6e 74 20 66 6c 61 67 73 ;.. int flags
0b40: 3b 09 09 2f 2a 20 73 65 65 20 53 74 61 74 65 2e ;../* see State.
0b50: 66 6c 61 67 73 20 61 62 6f 76 65 20 20 2a 2f 0a flags above */.
0b60: 20 20 20 20 69 6e 74 20 77 61 74 63 68 4d 61 73 int watchMas
0b70: 6b 3b 09 2f 2a 20 63 75 72 72 65 6e 74 20 57 61 k;./* current Wa
0b80: 74 63 68 50 72 6f 63 20 6d 61 73 6b 20 2a 2f 0a tchProc mask */.
0b90: 20 20 20 20 69 6e 74 20 6d 6f 64 65 3b 09 09 2f int mode;../
0ba0: 2a 20 63 75 72 72 65 6e 74 20 6d 6f 64 65 20 6f * current mode o
0bb0: 66 20 70 61 72 65 6e 74 20 63 68 61 6e 6e 65 6c f parent channel
0bc0: 20 2a 2f 0a 0a 20 20 20 20 54 63 6c 5f 49 6e 74 */.. Tcl_Int
0bd0: 65 72 70 20 2a 69 6e 74 65 72 70 3b 09 2f 2a 20 erp *interp;./*
0be0: 69 6e 74 65 72 70 72 65 74 65 72 20 69 6e 20 77 interpreter in w
0bf0: 68 69 63 68 20 74 68 69 73 20 72 65 73 69 64 65 hich this reside
0c00: 73 20 2a 2f 0a 20 20 20 20 54 63 6c 5f 4f 62 6a s */. Tcl_Obj
0c10: 20 2a 63 61 6c 6c 62 61 63 6b 3b 09 2f 2a 20 73 *callback;./* s
0c20: 63 72 69 70 74 20 63 61 6c 6c 65 64 20 66 6f 72 cript called for
0c30: 20 74 72 61 63 69 6e 67 2c 20 76 65 72 69 66 79 tracing, verify
0c40: 69 6e 67 20 61 6e 64 20 65 72 72 6f 72 73 20 2a ing and errors *
0c50: 2f 0a 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 70 /. Tcl_Obj *p
0c60: 61 73 73 77 6f 72 64 3b 09 2f 2a 20 73 63 72 69 assword;./* scri
0c70: 70 74 20 63 61 6c 6c 65 64 20 66 6f 72 20 63 65 pt called for ce
0c80: 72 74 69 66 69 63 61 74 65 20 70 61 73 73 77 6f rtificate passwo
0c90: 72 64 20 2a 2f 20 0a 0a 20 20 20 20 69 6e 74 20 rd */ .. int
0ca0: 76 66 6c 61 67 73 3b 09 09 2f 2a 20 76 65 72 69 vflags;../* veri
0cb0: 66 79 20 66 6c 61 67 73 20 2a 2f 0a 20 20 20 20 fy flags */.
0cc0: 53 53 4c 20 2a 73 73 6c 3b 09 09 2f 2a 20 53 74 SSL *ssl;../* St
0cd0: 72 75 63 74 20 66 6f 72 20 53 53 4c 20 70 72 6f ruct for SSL pro
0ce0: 63 65 73 73 69 6e 67 20 2a 2f 0a 20 20 20 20 53 cessing */. S
0cf0: 53 4c 5f 43 54 58 20 2a 63 74 78 3b 09 2f 2a 20 SL_CTX *ctx;./*
0d00: 53 53 4c 20 43 6f 6e 74 65 78 74 20 2a 2f 0a 20 SSL Context */.
0d10: 20 20 20 42 49 4f 20 2a 62 69 6f 3b 09 09 2f 2a BIO *bio;../*
0d20: 20 53 74 72 75 63 74 20 66 6f 72 20 53 53 4c 20 Struct for SSL
0d30: 70 72 6f 63 65 73 73 69 6e 67 20 2a 2f 0a 20 20 processing */.
0d40: 20 20 42 49 4f 20 2a 70 5f 62 69 6f 3b 09 09 2f BIO *p_bio;../
0d50: 2a 20 50 61 72 65 6e 74 20 42 49 4f 20 28 74 68 * Parent BIO (th
0d60: 61 74 20 69 73 20 6c 61 79 65 72 65 64 20 6f 6e at is layered on
0d70: 20 54 63 6c 5f 43 68 61 6e 6e 65 6c 29 20 2a 2f Tcl_Channel) */
0d80: 0a 0a 20 20 20 20 63 68 61 72 20 2a 65 72 72 3b .. char *err;
0d90: 0a 7d 20 53 74 61 74 65 3b 0a 0a 2f 2a 0a 20 2a .} State;../*. *
0da0: 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 64 The following d
0db0: 65 66 69 6e 69 74 69 6f 6e 73 20 68 61 76 65 20 efinitions have
0dc0: 74 6f 20 62 65 20 75 73 61 62 6c 65 20 66 6f 72 to be usable for
0dd0: 20 38 2e 32 2e 30 2d 38 2e 33 2e 31 20 61 6e 64 8.2.0-8.3.1 and
0de0: 20 38 2e 33 2e 32 2b 2e 0a 20 2a 20 54 68 65 20 8.3.2+.. * The
0df0: 64 69 66 66 65 72 65 6e 63 65 73 20 62 65 74 77 differences betw
0e00: 65 65 6e 20 74 68 65 73 65 20 76 65 72 73 69 6f een these versio
0e10: 6e 73 3a 0a 20 2a 0a 20 2a 20 38 2e 30 2d 38 2e ns:. *. * 8.0-8.
0e20: 31 3a 09 54 68 65 72 65 20 69 73 20 6e 6f 20 73 1:.There is no s
0e30: 75 70 70 6f 72 74 20 66 6f 72 20 74 68 65 73 65 upport for these
0e40: 20 69 6e 20 54 4c 53 20 31 2e 34 20 28 67 65 74 in TLS 1.4 (get
0e50: 20 31 2e 33 29 2e 20 20 54 68 69 73 0a 20 2a 09 1.3). This. *.
0e60: 09 77 61 73 20 74 68 65 20 76 65 72 73 69 6f 6e .was the version
0e70: 20 77 69 74 68 20 74 68 65 20 6f 72 69 67 69 6e with the origin
0e80: 61 6c 20 70 61 74 63 68 2e 0a 20 2a 0a 20 2a 20 al patch.. *. *
0e90: 38 2e 32 2e 30 2d 09 43 68 61 6e 67 65 64 20 73 8.2.0-.Changed s
0ea0: 65 6d 61 6e 74 69 63 73 20 66 6f 72 20 54 63 6c emantics for Tcl
0eb0: 5f 53 74 61 63 6b 43 68 61 6e 6e 65 6c 20 28 54 _StackChannel (T
0ec0: 63 6c 5f 52 65 70 6c 61 63 65 43 68 61 6e 6e 65 cl_ReplaceChanne
0ed0: 6c 29 2e 0a 20 2a 20 38 2e 33 2e 31 3a 09 43 68 l).. * 8.3.1:.Ch
0ee0: 65 63 6b 20 61 74 20 72 75 6e 74 69 6d 65 20 74 eck at runtime t
0ef0: 6f 20 73 77 69 74 63 68 20 74 68 65 20 62 65 68 o switch the beh
0f00: 61 76 69 6f 75 72 2e 20 54 68 65 20 70 61 74 63 aviour. The patc
0f10: 68 20 69 73 20 70 61 72 74 0a 20 2a 09 09 6f 66 h is part. *..of
0f20: 20 74 68 65 20 63 6f 72 65 20 66 72 6f 6d 20 6e the core from n
0f30: 6f 77 20 6f 6e 2e 0a 20 2a 0a 20 2a 20 38 2e 33 ow on.. *. * 8.3
0f40: 2e 32 2b 3a 09 53 74 61 63 6b 65 64 20 63 68 61 .2+:.Stacked cha
0f50: 6e 6e 65 6c 73 20 72 65 77 72 69 74 74 65 6e 20 nnels rewritten
0f60: 66 6f 72 20 62 65 74 74 65 72 20 62 65 68 61 76 for better behav
0f70: 69 6f 75 72 20 69 6e 20 73 6f 6d 65 0a 20 2a 09 iour in some. *.
0f80: 09 73 69 74 75 61 74 69 6f 6e 73 20 28 63 6c 6f .situations (clo
0f90: 73 69 6e 67 29 2e 20 53 6f 6d 65 20 6e 65 77 20 sing). Some new
0fa0: 41 50 49 27 73 2c 20 73 65 6d 61 6e 74 69 63 20 API's, semantic
0fb0: 63 68 61 6e 67 65 73 2e 0a 20 2a 0a 20 2a 20 54 changes.. *. * T
0fc0: 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 6d 61 67 he following mag
0fd0: 69 63 20 77 61 73 20 61 64 61 70 74 65 64 20 66 ic was adapted f
0fe0: 72 6f 6d 20 54 72 66 20 32 2e 31 20 28 4b 75 70 rom Trf 2.1 (Kup
0ff0: 72 69 65 73 29 2e 0a 20 2a 2f 0a 0a 23 64 65 66 ries).. */..#def
1000: 69 6e 65 20 54 4c 53 5f 43 48 41 4e 4e 45 4c 5f ine TLS_CHANNEL_
1010: 56 45 52 53 49 4f 4e 5f 31 09 30 78 31 0a 23 64 VERSION_1.0x1.#d
1020: 65 66 69 6e 65 20 54 4c 53 5f 43 48 41 4e 4e 45 efine TLS_CHANNE
1030: 4c 5f 56 45 52 53 49 4f 4e 5f 32 09 30 78 32 0a L_VERSION_2.0x2.
1040: 65 78 74 65 72 6e 20 69 6e 74 20 63 68 61 6e 6e extern int chann
1050: 65 6c 54 79 70 65 56 65 72 73 69 6f 6e 3b 0a 0a elTypeVersion;..
1060: 23 69 66 64 65 66 20 55 53 45 5f 54 43 4c 5f 53 #ifdef USE_TCL_S
1070: 54 55 42 53 0a 23 69 66 6e 64 65 66 20 54 63 6c TUBS.#ifndef Tcl
1080: 5f 53 74 61 63 6b 43 68 61 6e 6e 65 6c 0a 2f 2a _StackChannel./*
1090: 0a 20 2a 20 54 68 65 20 63 6f 72 65 20 77 65 20 . * The core we
10a0: 61 72 65 20 63 6f 6d 70 69 6c 69 6e 67 20 61 67 are compiling ag
10b0: 61 69 6e 73 74 20 69 73 20 6e 6f 74 20 70 61 74 ainst is not pat
10c0: 63 68 65 64 2c 20 73 6f 20 73 75 70 70 6c 79 20 ched, so supply
10d0: 74 68 65 0a 20 2a 20 6e 65 63 65 73 73 73 61 72 the. * necesssar
10e0: 79 20 64 65 66 69 6e 69 74 69 6f 6e 73 20 68 65 y definitions he
10f0: 72 65 20 62 79 20 6f 75 72 73 65 6c 76 65 73 2e re by ourselves.
1100: 20 54 68 65 20 66 6f 72 6d 20 63 68 6f 73 65 6e The form chosen
1110: 20 66 6f 72 0a 20 2a 20 74 68 65 20 70 72 6f 63 for. * the proc
1120: 65 64 75 72 65 20 6d 61 63 72 6f 73 20 28 72 65 edure macros (re
1130: 73 65 72 76 65 64 58 58 58 29 20 77 69 6c 6c 20 servedXXX) will
1140: 6e 6f 74 69 66 79 20 75 73 20 69 66 20 74 68 65 notify us if the
1150: 20 63 6f 72 65 0a 20 2a 20 64 6f 65 73 20 6e 6f core. * does no
1160: 74 20 68 61 76 65 20 74 68 65 73 65 20 72 65 73 t have these res
1170: 65 72 76 65 64 20 6c 6f 63 61 74 69 6f 6e 73 20 erved locations
1180: 61 6e 79 6d 6f 72 65 2e 0a 20 2a 0a 20 2a 20 21 anymore.. *. * !
1190: 21 20 53 79 6e 63 68 72 6f 6e 69 7a 65 20 74 68 ! Synchronize th
11a0: 65 20 70 72 6f 63 65 64 75 72 65 20 69 6e 64 69 e procedure indi
11b0: 63 65 73 20 69 6e 20 74 68 65 69 72 20 64 65 66 ces in their def
11c0: 69 6e 69 74 69 6f 6e 73 20 77 69 74 68 0a 20 2a initions with. *
11d0: 20 20 20 20 74 68 65 20 70 61 74 63 68 20 74 6f the patch to
11e0: 20 74 63 6c 2e 64 65 63 6c 73 2c 20 61 73 20 74 tcl.decls, as t
11f0: 68 65 79 20 68 61 76 65 20 74 6f 20 62 65 20 74 hey have to be t
1200: 68 65 20 73 61 6d 65 2e 0a 20 2a 2f 0a 0a 2f 2a he same.. */../*
1210: 20 32 38 31 20 2a 2f 0a 74 79 70 65 64 65 66 20 281 */.typedef
1220: 54 63 6c 5f 43 68 61 6e 6e 65 6c 20 28 74 6c 73 Tcl_Channel (tls
1230: 5f 53 74 61 63 6b 43 68 61 6e 6e 65 6c 29 20 5f _StackChannel) _
1240: 41 4e 53 49 5f 41 52 47 53 5f 28 28 54 63 6c 5f ANSI_ARGS_((Tcl_
1250: 49 6e 74 65 72 70 2a 20 69 6e 74 65 72 70 2c 0a Interp* interp,.
1260: 09 09 09 09 09 09 20 20 20 20 54 63 6c 5f 43 68 ...... Tcl_Ch
1270: 61 6e 6e 65 6c 54 79 70 65 2a 20 74 79 70 65 50 annelType* typeP
1280: 74 72 2c 0a 09 09 09 09 09 09 20 20 20 20 43 6c tr,....... Cl
1290: 69 65 6e 74 44 61 74 61 20 69 6e 73 74 61 6e 63 ientData instanc
12a0: 65 44 61 74 61 2c 0a 09 09 09 09 09 09 20 20 20 eData,.......
12b0: 20 69 6e 74 20 6d 61 73 6b 2c 0a 09 09 09 09 09 int mask,......
12c0: 09 20 20 20 20 54 63 6c 5f 43 68 61 6e 6e 65 6c . Tcl_Channel
12d0: 20 70 72 65 76 43 68 61 6e 29 29 3b 0a 2f 2a 20 prevChan));./*
12e0: 32 38 32 20 2a 2f 0a 74 79 70 65 64 65 66 20 76 282 */.typedef v
12f0: 6f 69 64 20 28 74 6c 73 5f 55 6e 73 74 61 63 6b oid (tls_Unstack
1300: 43 68 61 6e 6e 65 6c 29 20 5f 41 4e 53 49 5f 41 Channel) _ANSI_A
1310: 52 47 53 5f 28 28 54 63 6c 5f 49 6e 74 65 72 70 RGS_((Tcl_Interp
1320: 2a 20 69 6e 74 65 72 70 2c 0a 09 09 09 09 09 20 * interp,......
1330: 20 20 20 20 20 20 54 63 6c 5f 43 68 61 6e 6e 65 Tcl_Channe
1340: 6c 20 63 68 61 6e 29 29 3b 0a 0a 23 64 65 66 69 l chan));..#defi
1350: 6e 65 20 54 63 6c 5f 53 74 61 63 6b 43 68 61 6e ne Tcl_StackChan
1360: 6e 65 6c 20 20 20 20 20 28 28 74 6c 73 5f 53 74 nel ((tls_St
1370: 61 63 6b 43 68 61 6e 6e 65 6c 2a 29 20 74 63 6c ackChannel*) tcl
1380: 53 74 75 62 73 50 74 72 2d 3e 72 65 73 65 72 76 StubsPtr->reserv
1390: 65 64 32 38 31 29 0a 23 64 65 66 69 6e 65 20 54 ed281).#define T
13a0: 63 6c 5f 55 6e 73 74 61 63 6b 43 68 61 6e 6e 65 cl_UnstackChanne
13b0: 6c 20 28 28 74 6c 73 5f 55 6e 73 74 61 63 6b 43 l ((tls_UnstackC
13c0: 68 61 6e 6e 65 6c 2a 29 20 74 63 6c 53 74 75 62 hannel*) tclStub
13d0: 73 50 74 72 2d 3e 72 65 73 65 72 76 65 64 32 38 sPtr->reserved28
13e0: 32 29 0a 0a 23 65 6e 64 69 66 20 2f 2a 20 54 63 2)..#endif /* Tc
13f0: 6c 5f 53 74 61 63 6b 43 68 61 6e 6e 65 6c 20 2a l_StackChannel *
1400: 2f 0a 0a 23 69 66 6e 64 65 66 20 54 63 6c 5f 47 /..#ifndef Tcl_G
1410: 65 74 53 74 61 63 6b 65 64 43 68 61 6e 6e 65 6c etStackedChannel
1420: 0a 2f 2a 0a 20 2a 20 53 65 70 61 72 61 74 65 20 ./*. * Separate
1430: 64 65 66 69 6e 69 74 69 6f 6e 2c 20 61 76 61 69 definition, avai
1440: 6c 61 62 6c 65 20 69 6e 20 38 2e 32 2c 20 62 75 lable in 8.2, bu
1450: 74 20 6e 6f 74 20 38 2e 31 20 61 6e 64 20 62 65 t not 8.1 and be
1460: 66 6f 72 65 20 21 0a 20 2a 2f 0a 0a 2f 2a 20 32 fore !. */../* 2
1470: 38 33 20 2a 2f 0a 74 79 70 65 64 65 66 20 54 63 83 */.typedef Tc
1480: 6c 5f 43 68 61 6e 6e 65 6c 20 28 74 6c 73 5f 47 l_Channel (tls_G
1490: 65 74 53 74 61 63 6b 65 64 43 68 61 6e 6e 65 6c etStackedChannel
14a0: 29 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 54 ) _ANSI_ARGS_((T
14b0: 63 6c 5f 43 68 61 6e 6e 65 6c 20 63 68 61 6e 29 cl_Channel chan)
14c0: 29 3b 0a 0a 23 64 65 66 69 6e 65 20 54 63 6c 5f );..#define Tcl_
14d0: 47 65 74 53 74 61 63 6b 65 64 43 68 61 6e 6e 65 GetStackedChanne
14e0: 6c 20 28 28 74 6c 73 5f 47 65 74 53 74 61 63 6b l ((tls_GetStack
14f0: 65 64 43 68 61 6e 6e 65 6c 2a 29 20 74 63 6c 53 edChannel*) tclS
1500: 74 75 62 73 50 74 72 2d 3e 72 65 73 65 72 76 65 tubsPtr->reserve
1510: 64 32 38 33 29 0a 0a 23 65 6e 64 69 66 20 2f 2a d283)..#endif /*
1520: 20 54 63 6c 5f 47 65 74 53 74 61 63 6b 65 64 43 Tcl_GetStackedC
1530: 68 61 6e 6e 65 6c 20 2a 2f 0a 0a 0a 23 69 66 6e hannel */...#ifn
1540: 64 65 66 20 54 43 4c 5f 43 48 41 4e 4e 45 4c 5f def TCL_CHANNEL_
1550: 56 45 52 53 49 4f 4e 5f 32 0a 2f 2a 0a 20 2a 20 VERSION_2./*. *
1560: 43 6f 72 65 20 69 73 20 6f 6c 64 65 72 20 74 68 Core is older th
1570: 61 6e 20 38 2e 33 2e 32 2e 20 20 53 75 70 70 6c an 8.3.2. Suppl
1580: 79 20 74 68 65 20 6d 69 73 73 69 6e 67 20 64 65 y the missing de
1590: 66 69 6e 69 74 69 6f 6e 73 20 66 6f 72 0a 20 2a finitions for. *
15a0: 20 74 68 65 20 6e 65 77 20 41 50 49 27 73 20 69 the new API's i
15b0: 6e 20 38 2e 33 2e 32 2e 0a 20 2a 2f 0a 23 64 65 n 8.3.2.. */.#de
15c0: 66 69 6e 65 20 45 4d 55 4c 41 54 45 5f 43 48 41 fine EMULATE_CHA
15d0: 4e 4e 45 4c 5f 56 45 52 53 49 4f 4e 5f 32 0a 0a NNEL_VERSION_2..
15e0: 74 79 70 65 64 65 66 20 73 74 72 75 63 74 20 54 typedef struct T
15f0: 6c 73 43 68 61 6e 6e 65 6c 54 79 70 65 56 65 72 lsChannelTypeVer
1600: 73 69 6f 6e 5f 2a 20 54 6c 73 43 68 61 6e 6e 65 sion_* TlsChanne
1610: 6c 54 79 70 65 56 65 72 73 69 6f 6e 3b 0a 23 64 lTypeVersion;.#d
1620: 65 66 69 6e 65 20 54 43 4c 5f 43 48 41 4e 4e 45 efine TCL_CHANNE
1630: 4c 5f 56 45 52 53 49 4f 4e 5f 32 09 28 28 54 6c L_VERSION_2.((Tl
1640: 73 43 68 61 6e 6e 65 6c 54 79 70 65 56 65 72 73 sChannelTypeVers
1650: 69 6f 6e 29 20 30 78 32 29 0a 0a 74 79 70 65 64 ion) 0x2)..typed
1660: 65 66 20 69 6e 74 20 28 54 6c 73 44 72 69 76 65 ef int (TlsDrive
1670: 72 48 61 6e 64 6c 65 72 50 72 6f 63 29 20 5f 41 rHandlerProc) _A
1680: 4e 53 49 5f 41 52 47 53 5f 28 28 43 6c 69 65 6e NSI_ARGS_((Clien
1690: 74 44 61 74 61 20 69 6e 73 74 61 6e 63 65 44 61 tData instanceDa
16a0: 74 61 2c 0a 09 09 09 09 09 69 6e 74 20 69 6e 74 ta,......int int
16b0: 65 72 65 73 74 4d 61 73 6b 29 29 3b 0a 2f 2a 20 erestMask));./*
16c0: 33 39 34 20 2a 2f 0a 74 79 70 65 64 65 66 20 69 394 */.typedef i
16d0: 6e 74 20 28 74 6c 73 5f 52 65 61 64 52 61 77 29 nt (tls_ReadRaw)
16e0: 20 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 54 _ANSI_ARGS_((T
16f0: 63 6c 5f 43 68 61 6e 6e 65 6c 20 63 68 61 6e 2c cl_Channel chan,
1700: 20 63 68 61 72 20 2a 64 73 74 2c 0a 09 09 09 09 char *dst,.....
1710: 09 69 6e 74 20 62 79 74 65 73 54 6f 52 65 61 64 .int bytesToRead
1720: 29 29 3b 0a 2f 2a 20 33 39 35 20 2a 2f 0a 74 79 ));./* 395 */.ty
1730: 70 65 64 65 66 20 69 6e 74 20 28 74 6c 73 5f 57 pedef int (tls_W
1740: 72 69 74 65 52 61 77 29 20 5f 41 4e 53 49 5f 41 riteRaw) _ANSI_A
1750: 52 47 53 5f 28 28 54 63 6c 5f 43 68 61 6e 6e 65 RGS_((Tcl_Channe
1760: 6c 20 63 68 61 6e 2c 20 63 68 61 72 20 2a 73 72 l chan, char *sr
1770: 63 2c 0a 09 09 09 09 09 69 6e 74 20 73 72 63 4c c,......int srcL
1780: 65 6e 29 29 3b 0a 2f 2a 20 33 39 37 20 2a 2f 0a en));./* 397 */.
1790: 74 79 70 65 64 65 66 20 69 6e 74 20 28 74 6c 73 typedef int (tls
17a0: 5f 47 65 74 54 6f 70 43 68 61 6e 6e 65 6c 29 20 _GetTopChannel)
17b0: 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 54 63 6c _ANSI_ARGS_((Tcl
17c0: 5f 43 68 61 6e 6e 65 6c 20 63 68 61 6e 29 29 3b _Channel chan));
17d0: 0a 0a 2f 2a 0a 20 2a 20 47 65 6e 65 72 61 74 69 ../*. * Generati
17e0: 6e 67 20 63 6f 64 65 20 66 6f 72 20 61 63 63 65 ng code for acce
17f0: 73 73 69 6e 67 20 74 68 65 73 65 20 70 61 72 74 ssing these part
1800: 73 20 6f 66 20 74 68 65 20 73 74 75 62 20 74 61 s of the stub ta
1810: 62 6c 65 20 77 68 65 6e 0a 20 2a 20 63 6f 6d 70 ble when. * comp
1820: 69 6c 69 6e 67 20 61 67 61 69 6e 73 74 20 61 20 iling against a
1830: 63 6f 72 65 20 6f 6c 64 65 72 20 74 68 61 6e 20 core older than
1840: 38 2e 33 2e 32 20 69 73 20 61 20 68 61 73 73 6c 8.3.2 is a hassl
1850: 65 20 62 65 63 61 75 73 65 20 65 76 65 6e 0a 20 e because even.
1860: 2a 20 74 68 65 20 27 72 65 73 65 72 76 65 64 58 * the 'reservedX
1870: 58 58 27 20 66 69 65 6c 64 73 20 6f 66 20 74 68 XX' fields of th
1880: 65 20 73 74 72 75 63 74 75 72 65 20 61 72 65 20 e structure are
1890: 6e 6f 74 20 64 65 66 69 6e 65 64 20 79 65 74 2e not defined yet.
18a0: 20 53 6f 0a 20 2a 20 77 65 20 68 61 76 65 20 74 So. * we have t
18b0: 6f 20 77 72 69 74 65 20 75 70 20 73 6f 6d 65 20 o write up some
18c0: 6d 61 63 72 6f 73 20 68 69 64 69 6e 67 20 73 6f macros hiding so
18d0: 6d 65 20 76 65 72 79 20 68 61 63 6b 69 73 68 20 me very hackish
18e0: 70 6f 69 6e 74 65 72 0a 20 2a 20 61 72 69 74 68 pointer. * arith
18f0: 6d 65 74 69 63 73 20 74 6f 20 67 65 74 20 61 74 metics to get at
1900: 20 74 68 65 73 65 20 66 69 65 6c 64 73 2e 20 57 these fields. W
1910: 65 20 61 73 73 75 6d 65 20 74 68 61 74 20 70 6f e assume that po
1920: 69 6e 74 65 72 20 74 6f 0a 20 2a 20 66 75 6e 63 inter to. * func
1930: 74 69 6f 6e 73 20 61 72 65 20 61 6c 77 61 79 73 tions are always
1940: 20 6f 66 20 74 68 65 20 73 61 6d 65 20 73 69 7a of the same siz
1950: 65 2e 0a 20 2a 2f 0a 0a 23 64 65 66 69 6e 65 20 e.. */..#define
1960: 53 54 55 42 5f 42 41 53 45 20 20 20 28 28 63 68 STUB_BASE ((ch
1970: 61 72 2a 29 28 26 28 74 63 6c 53 74 75 62 73 50 ar*)(&(tclStubsP
1980: 74 72 2d 3e 74 63 6c 5f 55 74 66 4e 63 61 73 65 tr->tcl_UtfNcase
1990: 63 6d 70 29 29 29 20 2f 2a 20 66 69 65 6c 64 20 cmp))) /* field
19a0: 33 37 30 20 2a 2f 0a 23 64 65 66 69 6e 65 20 70 370 */.#define p
19b0: 72 6f 63 50 74 72 53 69 7a 65 20 28 73 69 7a 65 rocPtrSize (size
19c0: 6f 66 20 28 54 63 6c 5f 44 72 69 76 65 72 42 6c of (Tcl_DriverBl
19d0: 6f 63 6b 4d 6f 64 65 50 72 6f 63 20 2a 29 29 0a ockModeProc *)).
19e0: 23 64 65 66 69 6e 65 20 49 44 58 28 6e 29 20 20 #define IDX(n)
19f0: 20 20 20 20 28 28 28 6e 29 2d 33 37 30 29 20 2a (((n)-370) *
1a00: 20 70 72 6f 63 50 74 72 53 69 7a 65 29 0a 23 64 procPtrSize).#d
1a10: 65 66 69 6e 65 20 53 4c 4f 54 28 6e 29 20 20 20 efine SLOT(n)
1a20: 20 20 28 53 54 55 42 5f 42 41 53 45 20 2b 20 49 (STUB_BASE + I
1a30: 44 58 28 6e 29 29 0a 0a 23 64 65 66 69 6e 65 20 DX(n))..#define
1a40: 54 63 6c 5f 52 65 61 64 52 61 77 09 09 28 2a 28 Tcl_ReadRaw..(*(
1a50: 28 74 6c 73 5f 52 65 61 64 52 61 77 2a 2a 29 09 (tls_ReadRaw**).
1a60: 28 53 4c 4f 54 28 33 39 34 29 29 29 29 0a 23 64 (SLOT(394)))).#d
1a70: 65 66 69 6e 65 20 54 63 6c 5f 57 72 69 74 65 52 efine Tcl_WriteR
1a80: 61 77 09 09 28 2a 28 28 74 6c 73 5f 57 72 69 74 aw..(*((tls_Writ
1a90: 65 52 61 77 2a 2a 29 09 28 53 4c 4f 54 28 33 39 eRaw**).(SLOT(39
1aa0: 35 29 29 29 29 0a 23 64 65 66 69 6e 65 20 54 63 5)))).#define Tc
1ab0: 6c 5f 47 65 74 54 6f 70 43 68 61 6e 6e 65 6c 09 l_GetTopChannel.
1ac0: 28 2a 28 28 74 6c 73 5f 47 65 74 54 6f 70 43 68 (*((tls_GetTopCh
1ad0: 61 6e 6e 65 6c 2a 2a 29 28 53 4c 4f 54 28 33 39 annel**)(SLOT(39
1ae0: 36 29 29 29 29 0a 0a 2f 2a 0a 20 2a 20 52 65 71 6))))../*. * Req
1af0: 75 69 72 65 64 2c 20 65 61 73 79 20 65 6d 75 6c uired, easy emul
1b00: 61 74 69 6f 6e 2e 0a 20 2a 2f 0a 23 64 65 66 69 ation.. */.#defi
1b10: 6e 65 20 54 63 6c 5f 43 68 61 6e 6e 65 6c 47 65 ne Tcl_ChannelGe
1b20: 74 4f 70 74 69 6f 6e 50 72 6f 63 28 63 68 61 6e tOptionProc(chan
1b30: 44 72 69 76 65 72 29 20 28 28 63 68 61 6e 44 72 Driver) ((chanDr
1b40: 69 76 65 72 29 2d 3e 67 65 74 4f 70 74 69 6f 6e iver)->getOption
1b50: 50 72 6f 63 29 0a 0a 23 65 6e 64 69 66 20 2f 2a Proc)..#endif /*
1b60: 20 54 43 4c 5f 43 48 41 4e 4e 45 4c 5f 56 45 52 TCL_CHANNEL_VER
1b70: 53 49 4f 4e 5f 32 20 2a 2f 0a 0a 23 65 6e 64 69 SION_2 */..#endi
1b80: 66 20 2f 2a 20 55 53 45 5f 54 43 4c 5f 53 54 55 f /* USE_TCL_STU
1b90: 42 53 20 2a 2f 0a 0a 2f 2a 0a 20 2a 20 46 6f 72 BS */../*. * For
1ba0: 77 61 72 64 20 64 65 63 6c 61 72 61 74 69 6f 6e ward declaration
1bb0: 73 0a 20 2a 2f 0a 0a 45 58 54 45 52 4e 20 54 63 s. */..EXTERN Tc
1bc0: 6c 5f 43 68 61 6e 6e 65 6c 54 79 70 65 20 2a 54 l_ChannelType *T
1bd0: 6c 73 5f 43 68 61 6e 6e 65 6c 54 79 70 65 20 5f ls_ChannelType _
1be0: 41 4e 53 49 5f 41 52 47 53 5f 28 28 76 6f 69 64 ANSI_ARGS_((void
1bf0: 29 29 3b 0a 45 58 54 45 52 4e 20 54 63 6c 5f 43 ));.EXTERN Tcl_C
1c00: 68 61 6e 6e 65 6c 09 54 6c 73 5f 47 65 74 50 61 hannel.Tls_GetPa
1c10: 72 65 6e 74 20 5f 41 4e 53 49 5f 41 52 47 53 5f rent _ANSI_ARGS_
1c20: 28 28 53 74 61 74 65 20 2a 73 74 61 74 65 50 74 ((State *statePt
1c30: 72 29 29 3b 0a 0a 45 58 54 45 52 4e 20 54 63 6c r));..EXTERN Tcl
1c40: 5f 4f 62 6a 2a 09 09 54 6c 73 5f 4e 65 77 58 35 _Obj*..Tls_NewX5
1c50: 30 39 4f 62 6a 20 5f 41 4e 53 49 5f 41 52 47 53 09Obj _ANSI_ARGS
1c60: 5f 20 28 28 20 54 63 6c 5f 49 6e 74 65 72 70 20 _ (( Tcl_Interp
1c70: 2a 69 6e 74 65 72 70 2c 20 58 35 30 39 20 2a 63 *interp, X509 *c
1c80: 65 72 74 29 29 3b 0a 45 58 54 45 52 4e 20 76 6f ert));.EXTERN vo
1c90: 69 64 09 09 54 6c 73 5f 45 72 72 6f 72 20 5f 41 id..Tls_Error _A
1ca0: 4e 53 49 5f 41 52 47 53 5f 20 28 28 53 74 61 74 NSI_ARGS_ ((Stat
1cb0: 65 20 2a 73 74 61 74 65 50 74 72 2c 20 63 68 61 e *statePtr, cha
1cc0: 72 20 2a 6d 73 67 29 29 3b 0a 45 58 54 45 52 4e r *msg));.EXTERN
1cd0: 20 76 6f 69 64 09 09 54 6c 73 5f 46 72 65 65 20 void..Tls_Free
1ce0: 5f 41 4e 53 49 5f 41 52 47 53 5f 20 28 28 63 68 _ANSI_ARGS_ ((ch
1cf0: 61 72 20 2a 62 6c 6f 63 6b 50 74 72 29 29 3b 0a ar *blockPtr));.
1d00: 45 58 54 45 52 4e 20 76 6f 69 64 09 09 54 6c 73 EXTERN void..Tls
1d10: 5f 43 6c 65 61 6e 20 5f 41 4e 53 49 5f 41 52 47 _Clean _ANSI_ARG
1d20: 53 5f 20 28 28 53 74 61 74 65 20 2a 73 74 61 74 S_ ((State *stat
1d30: 65 50 74 72 29 29 3b 0a 45 58 54 45 52 4e 20 69 ePtr));.EXTERN i
1d40: 6e 74 09 09 54 6c 73 5f 57 61 69 74 46 6f 72 43 nt..Tls_WaitForC
1d50: 6f 6e 6e 65 63 74 20 5f 41 4e 53 49 5f 41 52 47 onnect _ANSI_ARG
1d60: 53 5f 28 28 20 53 74 61 74 65 20 2a 73 74 61 74 S_(( State *stat
1d70: 65 50 74 72 2c 0a 09 09 09 09 09 09 09 69 6e 74 ePtr,........int
1d80: 20 2a 65 72 72 6f 72 43 6f 64 65 50 74 72 29 29 *errorCodePtr))
1d90: 3b 0a 0a 45 58 54 45 52 4e 20 42 49 4f 5f 4d 45 ;..EXTERN BIO_ME
1da0: 54 48 4f 44 20 2a 09 42 49 4f 5f 73 5f 74 63 6c THOD *.BIO_s_tcl
1db0: 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 76 6f _ANSI_ARGS_((vo
1dc0: 69 64 29 29 3b 0a 45 58 54 45 52 4e 20 42 49 4f id));.EXTERN BIO
1dd0: 20 2a 09 09 42 49 4f 5f 6e 65 77 5f 74 63 6c 20 *..BIO_new_tcl
1de0: 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 53 74 61 _ANSI_ARGS_((Sta
1df0: 74 65 2a 20 73 74 61 74 65 50 74 72 2c 20 69 6e te* statePtr, in
1e00: 74 20 66 6c 61 67 73 29 29 3b 0a 0a 23 65 6e 64 t flags));..#end
1e10: 69 66 20 2f 2a 20 5f 54 4c 53 49 4e 54 5f 48 20 if /* _TLSINT_H
1e20: 2a 2f 0a */.