0000: 23 20 47 72 6f 75 70 2c 4e 61 6d 65 2c 43 6f 6e # Group,Name,Con
0010: 73 74 72 61 69 6e 74 73 2c 53 65 74 75 70 2c 42 straints,Setup,B
0020: 6f 64 79 2c 43 6c 65 61 6e 75 70 2c 4d 61 74 63 ody,Cleanup,Matc
0030: 68 2c 52 65 73 75 6c 74 2c 4f 75 74 70 75 74 2c h,Result,Output,
0040: 45 72 72 6f 72 20 4f 75 74 70 75 74 2c 52 65 74 Error Output,Ret
0050: 75 72 6e 20 43 6f 64 65 73 0a 63 6f 6d 6d 61 6e urn Codes.comman
0060: 64 2c 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 d,package requir
0070: 65 20 74 6c 73 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 2c e tls,,,,,,,,,.,
0080: 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e ,,,,,,,,,.comman
0090: 64 2c 23 20 43 6f 6e 73 74 72 61 69 6e 74 73 2c d,# Constraints,
00a0: 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e 64 ,,,,,,,,.command
00b0: 2c 73 6f 75 72 63 65 20 63 6f 6d 6d 6f 6e 2e 74 ,source common.t
00c0: 63 6c 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 2c 2c 2c 2c cl,,,,,,,,,.,,,,
00d0: 2c 2c 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 23 ,,,,,,.command,#
00e0: 20 48 65 6c 70 65 72 20 66 75 6e 63 74 69 6f 6e Helper function
00f0: 73 20 2d 20 53 65 65 20 63 6f 6d 6d 6f 6e 2e 74 s - See common.t
0100: 63 6c 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f 6d 6d cl,,,,,,,,,.comm
0110: 61 6e 64 2c 22 70 72 6f 63 20 72 65 61 64 5f 63 and,"proc read_c
0120: 68 61 6e 20 7b 66 69 6c 65 6e 61 6d 65 20 61 72 han {filename ar
0130: 67 73 7d 20 7b 73 65 74 20 63 68 20 5b 6f 70 65 gs} {set ch [ope
0140: 6e 20 24 66 69 6c 65 6e 61 6d 65 20 72 62 5d 3b n $filename rb];
0150: 73 65 74 20 62 73 69 7a 65 20 5b 66 63 6f 6e 66 set bsize [fconf
0160: 69 67 75 72 65 20 24 63 68 20 2d 62 75 66 66 65 igure $ch -buffe
0170: 72 73 69 7a 65 5d 3b 73 65 74 20 6e 65 77 20 5b rsize];set new [
0180: 7b 2a 7d 24 61 72 67 73 20 2d 63 68 61 6e 20 24 {*}$args -chan $
0190: 63 68 5d 3b 73 65 74 20 64 61 74 20 22 22 22 22 ch];set dat """"
01a0: 3b 77 68 69 6c 65 20 7b 21 5b 65 6f 66 20 24 6e ;while {![eof $n
01b0: 65 77 5d 7d 20 7b 61 70 70 65 6e 64 20 64 61 74 ew]} {append dat
01c0: 20 5b 72 65 61 64 20 24 6e 65 77 20 24 62 73 69 [read $new $bsi
01d0: 7a 65 5d 7d 3b 63 6c 6f 73 65 20 24 6e 65 77 3b ze]};close $new;
01e0: 72 65 74 75 72 6e 20 24 64 61 74 7d 22 2c 2c 2c return $dat}",,,
01f0: 2c 2c 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 70 ,,,,,,.command,p
0200: 72 6f 63 20 77 72 69 74 65 5f 63 68 61 6e 20 7b roc write_chan {
0210: 66 69 6c 65 6e 61 6d 65 20 64 61 74 61 20 61 72 filename data ar
0220: 67 73 7d 20 7b 73 65 74 20 63 68 20 5b 6f 70 65 gs} {set ch [ope
0230: 6e 20 24 66 69 6c 65 6e 61 6d 65 20 77 62 5d 3b n $filename wb];
0240: 73 65 74 20 6e 65 77 20 5b 7b 2a 7d 24 61 72 67 set new [{*}$arg
0250: 73 20 2d 63 68 61 6e 20 24 63 68 5d 3b 70 75 74 s -chan $ch];put
0260: 73 20 2d 6e 6f 6e 65 77 6c 69 6e 65 20 24 6e 65 s -nonewline $ne
0270: 77 20 24 64 61 74 61 3b 66 6c 75 73 68 20 24 6e w $data;flush $n
0280: 65 77 3b 63 6c 6f 73 65 20 24 6e 65 77 3b 73 65 ew;close $new;se
0290: 74 20 63 68 20 5b 6f 70 65 6e 20 24 66 69 6c 65 t ch [open $file
02a0: 6e 61 6d 65 20 72 62 5d 3b 73 65 74 20 64 61 74 name rb];set dat
02b0: 20 5b 72 65 61 64 20 24 63 68 5d 3b 63 6c 6f 73 [read $ch];clos
02c0: 65 20 24 63 68 3b 72 65 74 75 72 6e 20 24 64 61 e $ch;return $da
02d0: 74 7d 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f 6d 6d t},,,,,,,,,.comm
02e0: 61 6e 64 2c 22 70 72 6f 63 20 61 63 63 75 6d 75 and,"proc accumu
02f0: 6c 61 74 65 20 7b 73 74 72 69 6e 67 20 61 72 67 late {string arg
0300: 73 7d 20 7b 73 65 74 20 63 6d 64 20 5b 7b 2a 7d s} {set cmd [{*}
0310: 24 61 72 67 73 20 2d 63 6f 6d 6d 61 6e 64 20 64 $args -command d
0320: 63 6d 64 5d 3b 73 65 74 20 3a 3a 64 61 74 20 22 cmd];set ::dat "
0330: 22 22 22 3b 61 70 70 65 6e 64 20 3a 3a 64 61 74 """;append ::dat
0340: 20 5b 24 63 6d 64 20 75 70 64 61 74 65 20 5b 73 [$cmd update [s
0350: 74 72 69 6e 67 20 72 61 6e 67 65 20 24 73 74 72 tring range $str
0360: 69 6e 67 20 30 20 32 30 5d 5d 3b 61 70 70 65 6e ing 0 20]];appen
0370: 64 20 3a 3a 64 61 74 20 5b 24 63 6d 64 20 75 70 d ::dat [$cmd up
0380: 64 61 74 65 20 5b 73 74 72 69 6e 67 20 72 61 6e date [string ran
0390: 67 65 20 24 73 74 72 69 6e 67 20 32 31 20 65 6e ge $string 21 en
03a0: 64 5d 5d 3b 61 70 70 65 6e 64 20 3a 3a 64 61 74 d]];append ::dat
03b0: 20 5b 24 63 6d 64 20 66 69 6e 61 6c 69 7a 65 5d [$cmd finalize]
03c0: 7d 22 2c 24 63 6d 64 20 75 70 64 61 74 65 20 5b }",$cmd update [
03d0: 73 74 72 69 6e 67 20 72 61 6e 67 65 20 24 73 74 string range $st
03e0: 72 69 6e 67 20 30 20 32 30 5d 3b 24 63 6d 64 20 ring 0 20];$cmd
03f0: 75 70 64 61 74 65 20 5b 73 74 72 69 6e 67 20 72 update [string r
0400: 61 6e 67 65 20 24 73 74 72 69 6e 67 20 32 31 20 ange $string 21
0410: 65 6e 64 5d 3b 72 65 74 75 72 6e 20 5b 24 63 6d end];return [$cm
0420: 64 20 66 69 6e 61 6c 69 7a 65 5d 7d 2c 2c 2c 2c d finalize]},,,,
0430: 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 70 72 6f ,,,,.command,pro
0440: 63 20 67 65 74 5f 66 69 6c 65 5f 68 65 78 20 7b c get_file_hex {
0450: 66 69 6c 65 6e 61 6d 65 7d 20 7b 73 65 74 20 63 filename} {set c
0460: 68 20 5b 6f 70 65 6e 20 24 66 69 6c 65 6e 61 6d h [open $filenam
0470: 65 20 72 62 5d 3b 73 65 74 20 64 61 74 61 20 5b e rb];set data [
0480: 72 65 61 64 20 24 63 68 5d 3b 63 6c 6f 73 65 20 read $ch];close
0490: 24 63 68 3b 72 65 74 75 72 6e 20 5b 62 69 6e 61 $ch;return [bina
04a0: 72 79 20 65 6e 63 6f 64 65 20 68 65 78 20 24 64 ry encode hex $d
04b0: 61 74 61 5d 7d 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 ata]},,,,,,,,,.c
04c0: 6f 6d 6d 61 6e 64 2c 70 72 6f 63 20 67 65 74 5f ommand,proc get_
04d0: 66 69 6c 65 5f 74 65 78 74 20 7b 66 69 6c 65 6e file_text {filen
04e0: 61 6d 65 7d 20 7b 73 65 74 20 63 68 20 5b 6f 70 ame} {set ch [op
04f0: 65 6e 20 24 66 69 6c 65 6e 61 6d 65 20 72 5d 3b en $filename r];
0500: 73 65 74 20 64 61 74 61 20 5b 72 65 61 64 20 24 set data [read $
0510: 63 68 5d 3b 63 6c 6f 73 65 20 24 63 68 3b 72 65 ch];close $ch;re
0520: 74 75 72 6e 20 24 64 61 74 61 7d 2c 2c 2c 2c 2c turn $data},,,,,
0530: 2c 2c 2c 2c 0a 2c 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a ,,,,.,,,,,,,,,,.
0540: 63 6f 6d 6d 61 6e 64 2c 22 73 65 74 20 74 65 73 command,"set tes
0550: 74 5f 64 61 74 61 20 22 22 45 78 61 6d 70 6c 65 t_data ""Example
0560: 20 73 74 72 69 6e 67 20 66 6f 72 20 6d 65 73 73 string for mess
0570: 61 67 65 20 64 69 67 65 73 74 20 74 65 73 74 73 age digest tests
0580: 2e 5c 6e 22 22 22 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a .\n""",,,,,,,,,.
0590: 63 6f 6d 6d 61 6e 64 2c 22 73 65 74 20 75 6e 65 command,"set une
05a0: 6e 63 72 79 70 74 65 64 5f 66 69 6c 65 20 22 22 ncrypted_file ""
05b0: 75 6e 65 6e 63 72 79 70 74 65 64 5f 64 61 74 61 unencrypted_data
05c0: 2e 64 61 74 22 22 22 2c 2c 2c 2c 2c 2c 2c 2c 2c .dat""",,,,,,,,,
05d0: 0a 63 6f 6d 6d 61 6e 64 2c 22 73 65 74 20 65 6e .command,"set en
05e0: 63 72 79 70 74 65 64 5f 66 69 6c 65 20 22 22 65 crypted_file ""e
05f0: 6e 63 72 79 70 74 65 64 5f 64 61 74 61 2e 64 61 ncrypted_data.da
0600: 74 22 22 22 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f t""",,,,,,,,,.co
0610: 6d 6d 61 6e 64 2c 22 73 65 74 20 61 6c 74 5f 66 mmand,"set alt_f
0620: 69 6c 65 20 22 22 72 65 73 75 6c 74 5f 64 61 74 ile ""result_dat
0630: 61 2e 64 61 74 22 22 22 2c 2c 2c 2c 2c 2c 2c 2c a.dat""",,,,,,,,
0640: 2c 0a 63 6f 6d 6d 61 6e 64 2c 22 73 65 74 20 74 ,.command,"set t
0650: 65 73 74 5f 6b 65 79 20 22 22 45 78 61 6d 70 6c est_key ""Exampl
0660: 65 20 6b 65 79 22 22 22 2c 2c 2c 2c 2c 2c 2c 2c e key""",,,,,,,,
0670: 2c 0a 63 6f 6d 6d 61 6e 64 2c 22 73 65 74 20 74 ,.command,"set t
0680: 65 73 74 5f 69 76 20 22 22 45 78 61 6d 70 6c 65 est_iv ""Example
0690: 20 69 76 22 22 22 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a iv""",,,,,,,,,.
06a0: 63 6f 6d 6d 61 6e 64 2c 3a 3a 74 63 6c 74 65 73 command,::tcltes
06b0: 74 3a 3a 6d 61 6b 65 46 69 6c 65 20 24 74 65 73 t::makeFile $tes
06c0: 74 5f 64 61 74 61 20 24 75 6e 65 6e 63 72 79 70 t_data $unencryp
06d0: 74 65 64 5f 66 69 6c 65 2c 2c 2c 2c 2c 2c 2c 2c ted_file,,,,,,,,
06e0: 2c 0a 20 2c 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f ,. ,,,,,,,,,,.co
06f0: 6d 6d 61 6e 64 2c 23 20 54 65 73 74 20 65 6e 63 mmand,# Test enc
0700: 72 79 70 74 20 64 61 74 61 2c 2c 2c 2c 2c 2c 2c rypt data,,,,,,,
0710: 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 73 65 74 20 63 ,,.command,set c
0720: 69 70 68 65 72 20 61 65 73 2d 31 32 38 2d 63 62 ipher aes-128-cb
0730: 63 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f 6d 6d 61 c,,,,,,,,,.comma
0740: 6e 64 2c 22 73 65 74 20 68 65 78 5f 73 74 72 69 nd,"set hex_stri
0750: 6e 67 20 22 22 33 63 65 61 30 33 34 33 39 38 64 ng ""3cea034398d
0760: 65 36 34 35 30 37 61 62 62 63 37 62 63 66 36 61 e64507abbc7bcf6a
0770: 63 62 61 35 35 63 37 30 31 31 31 30 30 63 39 30 cba55c7011100c90
0780: 31 35 63 32 32 62 33 63 39 63 33 33 31 64 31 38 15c22b3c9c331d18
0790: 34 37 39 66 65 64 35 65 35 34 32 63 65 30 32 61 479fed5e542ce02a
07a0: 33 62 38 39 61 30 66 37 35 30 64 61 66 38 65 32 3b89a0f750daf8e2
07b0: 61 34 39 34 65 22 22 22 2c 2c 2c 2c 2c 2c 2c 2c a494e""",,,,,,,,
07c0: 2c 0a 45 6e 63 72 79 70 74 20 44 65 63 72 79 70 ,.Encrypt Decryp
07d0: 74 20 44 61 74 61 2c 45 6e 63 72 79 70 74 20 61 t Data,Encrypt a
07e0: 65 73 2d 31 33 38 2d 63 62 63 2c 2c 2c 62 69 6e es-138-cbc,,,bin
07f0: 61 72 79 20 65 6e 63 6f 64 65 20 68 65 78 20 5b ary encode hex [
0800: 73 65 74 20 64 61 74 61 20 5b 74 6c 73 3a 3a 65 set data [tls::e
0810: 6e 63 72 79 70 74 20 2d 63 69 70 68 65 72 20 24 ncrypt -cipher $
0820: 63 69 70 68 65 72 20 2d 6b 65 79 20 24 74 65 73 cipher -key $tes
0830: 74 5f 6b 65 79 20 2d 69 76 20 24 74 65 73 74 5f t_key -iv $test_
0840: 69 76 20 2d 64 61 74 61 20 24 74 65 73 74 5f 64 iv -data $test_d
0850: 61 74 61 5d 5d 2c 2c 2c 24 68 65 78 5f 73 74 72 ata]],,,$hex_str
0860: 69 6e 67 2c 2c 2c 0a 45 6e 63 72 79 70 74 20 44 ing,,,.Encrypt D
0870: 65 63 72 79 70 74 20 44 61 74 61 2c 44 65 63 72 ecrypt Data,Decr
0880: 79 70 74 20 61 65 73 2d 31 32 38 2d 63 62 63 2c ypt aes-128-cbc,
0890: 2c 2c 74 6c 73 3a 3a 64 65 63 72 79 70 74 20 2d ,,tls::decrypt -
08a0: 63 69 70 68 65 72 20 24 63 69 70 68 65 72 20 2d cipher $cipher -
08b0: 6b 65 79 20 24 74 65 73 74 5f 6b 65 79 20 2d 69 key $test_key -i
08c0: 76 20 24 74 65 73 74 5f 69 76 20 2d 64 61 74 61 v $test_iv -data
08d0: 20 24 64 61 74 61 2c 2c 2c 24 74 65 73 74 5f 64 $data,,,$test_d
08e0: 61 74 61 2c 2c 2c 0a 20 2c 2c 2c 2c 2c 2c 2c 2c ata,,,. ,,,,,,,,
08f0: 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 23 20 54 65 73 ,,.command,# Tes
0900: 74 20 65 6e 63 72 79 70 74 20 66 69 6c 65 2c 2c t encrypt file,,
0910: 2c 2c 2c 2c 2c 2c 2c 0a 45 6e 63 72 79 70 74 20 ,,,,,,,.Encrypt
0920: 44 65 63 72 79 70 74 20 46 69 6c 65 2c 45 6e 63 Decrypt File,Enc
0930: 72 79 70 74 20 61 65 73 2d 31 33 38 2d 63 62 63 rypt aes-138-cbc
0940: 2c 2c 2c 74 6c 73 3a 3a 65 6e 63 72 79 70 74 20 ,,,tls::encrypt
0950: 2d 63 69 70 68 65 72 20 24 63 69 70 68 65 72 20 -cipher $cipher
0960: 2d 6b 65 79 20 24 74 65 73 74 5f 6b 65 79 20 2d -key $test_key -
0970: 69 76 20 24 74 65 73 74 5f 69 76 20 2d 69 6e 66 iv $test_iv -inf
0980: 69 6c 65 20 24 75 6e 65 6e 63 72 79 70 74 65 64 ile $unencrypted
0990: 5f 66 69 6c 65 20 2d 6f 75 74 66 69 6c 65 20 24 _file -outfile $
09a0: 65 6e 63 72 79 70 74 65 64 5f 66 69 6c 65 3b 67 encrypted_file;g
09b0: 65 74 5f 66 69 6c 65 5f 68 65 78 20 24 65 6e 63 et_file_hex $enc
09c0: 72 79 70 74 65 64 5f 66 69 6c 65 2c 2c 2c 24 68 rypted_file,,,$h
09d0: 65 78 5f 73 74 72 69 6e 67 2c 2c 2c 0a 45 6e 63 ex_string,,,.Enc
09e0: 72 79 70 74 20 44 65 63 72 79 70 74 20 46 69 6c rypt Decrypt Fil
09f0: 65 2c 44 65 63 72 79 70 74 20 61 65 73 2d 31 32 e,Decrypt aes-12
0a00: 38 2d 63 62 63 2c 2c 2c 74 6c 73 3a 3a 64 65 63 8-cbc,,,tls::dec
0a10: 72 79 70 74 20 2d 63 69 70 68 65 72 20 24 63 69 rypt -cipher $ci
0a20: 70 68 65 72 20 2d 6b 65 79 20 24 74 65 73 74 5f pher -key $test_
0a30: 6b 65 79 20 2d 69 76 20 24 74 65 73 74 5f 69 76 key -iv $test_iv
0a40: 20 2d 69 6e 66 69 6c 65 20 24 65 6e 63 72 79 70 -infile $encryp
0a50: 74 65 64 5f 66 69 6c 65 20 2d 6f 75 74 66 69 6c ted_file -outfil
0a60: 65 20 24 61 6c 74 5f 66 69 6c 65 3b 67 65 74 5f e $alt_file;get_
0a70: 66 69 6c 65 5f 74 65 78 74 20 24 61 6c 74 5f 66 file_text $alt_f
0a80: 69 6c 65 2c 2c 2c 24 74 65 73 74 5f 64 61 74 61 ile,,,$test_data
0a90: 2c 2c 2c 0a 20 2c 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a ,,,. ,,,,,,,,,,.
0aa0: 63 6f 6d 6d 61 6e 64 2c 23 20 54 65 73 74 20 65 command,# Test e
0ab0: 6e 63 72 79 70 74 20 75 73 69 6e 67 20 6f 62 6a ncrypt using obj
0ac0: 65 63 74 20 63 6f 6d 6d 61 6e 64 2c 2c 2c 2c 2c ect command,,,,,
0ad0: 2c 2c 2c 2c 0a 45 6e 63 72 79 70 74 20 44 65 63 ,,,,.Encrypt Dec
0ae0: 72 79 70 74 20 43 6f 6d 6d 61 6e 64 2c 45 6e 63 rypt Command,Enc
0af0: 72 79 70 74 20 61 65 73 2d 31 33 38 2d 63 62 63 rypt aes-138-cbc
0b00: 2c 2c 2c 61 63 63 75 6d 75 6c 61 74 65 20 24 74 ,,,accumulate $t
0b10: 65 73 74 5f 64 61 74 61 20 74 6c 73 3a 3a 65 6e est_data tls::en
0b20: 63 72 79 70 74 20 2d 63 69 70 68 65 72 20 24 63 crypt -cipher $c
0b30: 69 70 68 65 72 20 2d 6b 65 79 20 24 74 65 73 74 ipher -key $test
0b40: 5f 6b 65 79 20 2d 69 76 20 24 74 65 73 74 5f 69 _key -iv $test_i
0b50: 76 3b 62 69 6e 61 72 79 20 65 6e 63 6f 64 65 20 v;binary encode
0b60: 68 65 78 20 24 3a 3a 64 61 74 2c 2c 2c 24 68 65 hex $::dat,,,$he
0b70: 78 5f 73 74 72 69 6e 67 2c 2c 2c 0a 45 6e 63 72 x_string,,,.Encr
0b80: 79 70 74 20 44 65 63 72 79 70 74 20 43 6f 6d 6d ypt Decrypt Comm
0b90: 61 6e 64 2c 44 65 63 72 79 70 74 20 61 65 73 2d and,Decrypt aes-
0ba0: 31 32 38 2d 63 62 63 2c 2c 2c 61 63 63 75 6d 75 128-cbc,,,accumu
0bb0: 6c 61 74 65 20 24 3a 3a 64 61 74 20 74 6c 73 3a late $::dat tls:
0bc0: 3a 64 65 63 72 79 70 74 20 2d 63 69 70 68 65 72 :decrypt -cipher
0bd0: 20 24 63 69 70 68 65 72 20 2d 6b 65 79 20 24 74 $cipher -key $t
0be0: 65 73 74 5f 6b 65 79 20 2d 69 76 20 24 74 65 73 est_key -iv $tes
0bf0: 74 5f 69 76 3b 73 65 74 20 3a 3a 64 61 74 2c 2c t_iv;set ::dat,,
0c00: 2c 24 74 65 73 74 5f 64 61 74 61 2c 2c 2c 0a 20 ,$test_data,,,.
0c10: 2c 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f 6d 6d 61 ,,,,,,,,,,.comma
0c20: 6e 64 2c 23 20 54 65 73 74 20 65 6e 63 72 79 70 nd,# Test encryp
0c30: 74 20 75 73 69 6e 67 20 72 65 61 64 20 63 68 61 t using read cha
0c40: 6e 6e 65 6c 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 45 6e nnel,,,,,,,,,.En
0c50: 63 72 79 70 74 20 44 65 63 72 79 70 74 20 43 68 crypt Decrypt Ch
0c60: 61 6e 6e 65 6c 20 52 65 61 64 2c 45 6e 63 72 79 annel Read,Encry
0c70: 70 74 20 61 65 73 2d 31 33 38 2d 63 62 63 2c 2c pt aes-138-cbc,,
0c80: 2c 62 69 6e 61 72 79 20 65 6e 63 6f 64 65 20 68 ,binary encode h
0c90: 65 78 20 5b 72 65 61 64 5f 63 68 61 6e 20 24 75 ex [read_chan $u
0ca0: 6e 65 6e 63 72 79 70 74 65 64 5f 66 69 6c 65 20 nencrypted_file
0cb0: 74 6c 73 3a 3a 65 6e 63 72 79 70 74 20 2d 63 69 tls::encrypt -ci
0cc0: 70 68 65 72 20 24 63 69 70 68 65 72 20 2d 6b 65 pher $cipher -ke
0cd0: 79 20 24 74 65 73 74 5f 6b 65 79 20 2d 69 76 20 y $test_key -iv
0ce0: 24 74 65 73 74 5f 69 76 5d 2c 2c 2c 24 68 65 78 $test_iv],,,$hex
0cf0: 5f 73 74 72 69 6e 67 2c 2c 2c 0a 45 6e 63 72 79 _string,,,.Encry
0d00: 70 74 20 44 65 63 72 79 70 74 20 43 68 61 6e 6e pt Decrypt Chann
0d10: 65 6c 20 52 65 61 64 2c 44 65 63 72 79 70 74 20 el Read,Decrypt
0d20: 61 65 73 2d 31 33 38 2d 63 62 63 2c 2c 2c 72 65 aes-138-cbc,,,re
0d30: 61 64 5f 63 68 61 6e 20 24 65 6e 63 72 79 70 74 ad_chan $encrypt
0d40: 65 64 5f 66 69 6c 65 20 74 6c 73 3a 3a 64 65 63 ed_file tls::dec
0d50: 72 79 70 74 20 2d 63 69 70 68 65 72 20 24 63 69 rypt -cipher $ci
0d60: 70 68 65 72 20 2d 6b 65 79 20 24 74 65 73 74 5f pher -key $test_
0d70: 6b 65 79 20 2d 69 76 20 24 74 65 73 74 5f 69 76 key -iv $test_iv
0d80: 2c 2c 2c 24 74 65 73 74 5f 64 61 74 61 2c 2c 2c ,,,$test_data,,,
0d90: 0a 20 2c 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f 6d . ,,,,,,,,,,.com
0da0: 6d 61 6e 64 2c 23 20 54 65 73 74 20 65 6e 63 72 mand,# Test encr
0db0: 79 70 74 20 75 73 69 6e 67 20 77 72 69 74 65 20 ypt using write
0dc0: 63 68 61 6e 6e 65 6c 2c 2c 2c 2c 2c 2c 2c 2c 2c channel,,,,,,,,,
0dd0: 0a 45 6e 63 72 79 70 74 20 44 65 63 72 79 70 74 .Encrypt Decrypt
0de0: 20 43 68 61 6e 6e 65 6c 20 57 72 69 74 65 2c 45 Channel Write,E
0df0: 6e 63 72 79 70 74 20 61 65 73 2d 31 33 38 2d 63 ncrypt aes-138-c
0e00: 62 63 2c 2c 2c 62 69 6e 61 72 79 20 65 6e 63 6f bc,,,binary enco
0e10: 64 65 20 68 65 78 20 5b 73 65 74 20 64 61 74 61 de hex [set data
0e20: 20 5b 77 72 69 74 65 5f 63 68 61 6e 20 24 65 6e [write_chan $en
0e30: 63 72 79 70 74 65 64 5f 66 69 6c 65 20 24 74 65 crypted_file $te
0e40: 73 74 5f 64 61 74 61 20 74 6c 73 3a 3a 65 6e 63 st_data tls::enc
0e50: 72 79 70 74 20 2d 63 69 70 68 65 72 20 24 63 69 rypt -cipher $ci
0e60: 70 68 65 72 20 2d 6b 65 79 20 24 74 65 73 74 5f pher -key $test_
0e70: 6b 65 79 20 2d 69 76 20 24 74 65 73 74 5f 69 76 key -iv $test_iv
0e80: 5d 5d 2c 2c 2c 24 68 65 78 5f 73 74 72 69 6e 67 ]],,,$hex_string
0e90: 2c 2c 2c 0a 45 6e 63 72 79 70 74 20 44 65 63 72 ,,,.Encrypt Decr
0ea0: 79 70 74 20 43 68 61 6e 6e 65 6c 20 57 72 69 74 ypt Channel Writ
0eb0: 65 2c 44 65 63 72 79 70 74 20 61 65 73 2d 31 33 e,Decrypt aes-13
0ec0: 38 2d 63 62 63 2c 2c 2c 77 72 69 74 65 5f 63 68 8-cbc,,,write_ch
0ed0: 61 6e 20 24 61 6c 74 5f 66 69 6c 65 20 24 64 61 an $alt_file $da
0ee0: 74 61 20 74 6c 73 3a 3a 64 65 63 72 79 70 74 20 ta tls::decrypt
0ef0: 2d 63 69 70 68 65 72 20 24 63 69 70 68 65 72 20 -cipher $cipher
0f00: 2d 6b 65 79 20 24 74 65 73 74 5f 6b 65 79 20 2d -key $test_key -
0f10: 69 76 20 24 74 65 73 74 5f 69 76 2c 2c 2c 24 74 iv $test_iv,,,$t
0f20: 65 73 74 5f 64 61 74 61 2c 2c 2c 0a 2c 2c 2c 2c est_data,,,.,,,,
0f30: 2c 2c 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 23 ,,,,,,.command,#
0f40: 20 43 6c 65 61 6e 75 70 2c 2c 2c 2c 2c 2c 2c 2c Cleanup,,,,,,,,
0f50: 2c 0a 63 6f 6d 6d 61 6e 64 2c 3a 3a 74 63 6c 74 ,.command,::tclt
0f60: 65 73 74 3a 3a 72 65 6d 6f 76 65 46 69 6c 65 20 est::removeFile
0f70: 24 75 6e 65 6e 63 72 79 70 74 65 64 5f 66 69 6c $unencrypted_fil
0f80: 65 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f 6d 6d 61 e,,,,,,,,,.comma
0f90: 6e 64 2c 3a 3a 74 63 6c 74 65 73 74 3a 3a 72 65 nd,::tcltest::re
0fa0: 6d 6f 76 65 46 69 6c 65 20 24 65 6e 63 72 79 70 moveFile $encryp
0fb0: 74 65 64 5f 66 69 6c 65 2c 2c 2c 2c 2c 2c 2c 2c ted_file,,,,,,,,
0fc0: 2c 0a 63 6f 6d 6d 61 6e 64 2c 3a 3a 74 63 6c 74 ,.command,::tclt
0fd0: 65 73 74 3a 3a 72 65 6d 6f 76 65 46 69 6c 65 20 est::removeFile
0fe0: 24 61 6c 74 5f 66 69 6c 65 2c 2c 2c 2c 2c 2c 2c $alt_file,,,,,,,
0ff0: 2c 2c 0a ,,.