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 48 65 6c 70 65 72 20 66 75 6e 63 74  d,# Helper funct
00a0: 69 6f 6e 73 20 2d 20 53 65 65 20 63 6f 6d 6d 6f  ions - See commo
00b0: 6e 2e 74 63 6c 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63  n.tcl,,,,,,,,,.c
00c0: 6f 6d 6d 61 6e 64 2c 22 70 72 6f 63 20 72 65 61  ommand,"proc rea
00d0: 64 5f 63 68 61 6e 20 7b 66 69 6c 65 6e 61 6d 65  d_chan {filename
00e0: 20 61 72 67 73 7d 20 7b 73 65 74 20 63 68 20 5b   args} {set ch [
00f0: 6f 70 65 6e 20 24 66 69 6c 65 6e 61 6d 65 20 72  open $filename r
0100: 62 5d 3b 73 65 74 20 62 73 69 7a 65 20 5b 66 63  b];set bsize [fc
0110: 6f 6e 66 69 67 75 72 65 20 24 63 68 20 2d 62 75  onfigure $ch -bu
0120: 66 66 65 72 73 69 7a 65 5d 3b 73 65 74 20 6e 65  ffersize];set ne
0130: 77 20 5b 7b 2a 7d 24 61 72 67 73 20 2d 63 68 61  w [{*}$args -cha
0140: 6e 20 24 63 68 5d 3b 73 65 74 20 64 61 74 20 22  n $ch];set dat "
0150: 22 22 22 3b 77 68 69 6c 65 20 7b 21 5b 65 6f 66  """;while {![eof
0160: 20 24 6e 65 77 5d 7d 20 7b 61 70 70 65 6e 64 20   $new]} {append 
0170: 64 61 74 20 5b 72 65 61 64 20 24 6e 65 77 20 24  dat [read $new $
0180: 62 73 69 7a 65 5d 7d 3b 63 6c 6f 73 65 20 24 6e  bsize]};close $n
0190: 65 77 3b 72 65 74 75 72 6e 20 24 64 61 74 7d 22  ew;return $dat}"
01a0: 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e  ,,,,,,,,,.comman
01b0: 64 2c 70 72 6f 63 20 77 72 69 74 65 5f 63 68 61  d,proc write_cha
01c0: 6e 20 7b 66 69 6c 65 6e 61 6d 65 20 64 61 74 61  n {filename data
01d0: 20 61 72 67 73 7d 20 7b 73 65 74 20 63 68 20 5b   args} {set ch [
01e0: 6f 70 65 6e 20 24 66 69 6c 65 6e 61 6d 65 20 77  open $filename w
01f0: 62 5d 3b 73 65 74 20 6e 65 77 20 5b 7b 2a 7d 24  b];set new [{*}$
0200: 61 72 67 73 20 2d 63 68 61 6e 20 24 63 68 5d 3b  args -chan $ch];
0210: 70 75 74 73 20 2d 6e 6f 6e 65 77 6c 69 6e 65 20  puts -nonewline 
0220: 24 6e 65 77 20 24 64 61 74 61 3b 66 6c 75 73 68  $new $data;flush
0230: 20 24 6e 65 77 3b 63 6c 6f 73 65 20 24 6e 65 77   $new;close $new
0240: 3b 73 65 74 20 63 68 20 5b 6f 70 65 6e 20 24 66  ;set ch [open $f
0250: 69 6c 65 6e 61 6d 65 20 72 62 5d 3b 73 65 74 20  ilename rb];set 
0260: 64 61 74 20 5b 72 65 61 64 20 24 63 68 5d 3b 63  dat [read $ch];c
0270: 6c 6f 73 65 20 24 63 68 3b 72 65 74 75 72 6e 20  lose $ch;return 
0280: 24 64 61 74 7d 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63  $dat},,,,,,,,,.c
0290: 6f 6d 6d 61 6e 64 2c 22 70 72 6f 63 20 61 63 63  ommand,"proc acc
02a0: 75 6d 75 6c 61 74 65 20 7b 73 74 72 69 6e 67 20  umulate {string 
02b0: 61 72 67 73 7d 20 7b 73 65 74 20 63 6d 64 20 5b  args} {set cmd [
02c0: 7b 2a 7d 24 61 72 67 73 20 2d 63 6f 6d 6d 61 6e  {*}$args -comman
02d0: 64 20 64 63 6d 64 5d 3b 73 65 74 20 3a 3a 64 61  d dcmd];set ::da
02e0: 74 20 22 22 22 22 3b 61 70 70 65 6e 64 20 3a 3a  t """";append ::
02f0: 64 61 74 20 5b 24 63 6d 64 20 75 70 64 61 74 65  dat [$cmd update
0300: 20 5b 73 74 72 69 6e 67 20 72 61 6e 67 65 20 24   [string range $
0310: 73 74 72 69 6e 67 20 30 20 32 30 5d 5d 3b 61 70  string 0 20]];ap
0320: 70 65 6e 64 20 3a 3a 64 61 74 20 5b 24 63 6d 64  pend ::dat [$cmd
0330: 20 75 70 64 61 74 65 20 5b 73 74 72 69 6e 67 20   update [string 
0340: 72 61 6e 67 65 20 24 73 74 72 69 6e 67 20 32 31  range $string 21
0350: 20 65 6e 64 5d 5d 3b 61 70 70 65 6e 64 20 3a 3a   end]];append ::
0360: 64 61 74 20 5b 24 63 6d 64 20 66 69 6e 61 6c 69  dat [$cmd finali
0370: 7a 65 5d 7d 22 2c 24 63 6d 64 20 75 70 64 61 74  ze]}",$cmd updat
0380: 65 20 5b 73 74 72 69 6e 67 20 72 61 6e 67 65 20  e [string range 
0390: 24 73 74 72 69 6e 67 20 30 20 32 30 5d 3b 24 63  $string 0 20];$c
03a0: 6d 64 20 75 70 64 61 74 65 20 5b 73 74 72 69 6e  md update [strin
03b0: 67 20 72 61 6e 67 65 20 24 73 74 72 69 6e 67 20  g range $string 
03c0: 32 31 20 65 6e 64 5d 3b 72 65 74 75 72 6e 20 5b  21 end];return [
03d0: 24 63 6d 64 20 66 69 6e 61 6c 69 7a 65 5d 7d 2c  $cmd finalize]},
03e0: 2c 2c 2c 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c  ,,,,,,,.command,
03f0: 70 72 6f 63 20 67 65 74 5f 66 69 6c 65 5f 68 65  proc get_file_he
0400: 78 20 7b 66 69 6c 65 6e 61 6d 65 7d 20 7b 73 65  x {filename} {se
0410: 74 20 63 68 20 5b 6f 70 65 6e 20 24 66 69 6c 65  t ch [open $file
0420: 6e 61 6d 65 20 72 62 5d 3b 73 65 74 20 64 61 74  name rb];set dat
0430: 61 20 5b 72 65 61 64 20 24 63 68 5d 3b 63 6c 6f  a [read $ch];clo
0440: 73 65 20 24 63 68 3b 72 65 74 75 72 6e 20 5b 62  se $ch;return [b
0450: 69 6e 61 72 79 20 65 6e 63 6f 64 65 20 68 65 78  inary encode hex
0460: 20 24 64 61 74 61 5d 7d 2c 2c 2c 2c 2c 2c 2c 2c   $data]},,,,,,,,
0470: 2c 0a 63 6f 6d 6d 61 6e 64 2c 70 72 6f 63 20 67  ,.command,proc g
0480: 65 74 5f 66 69 6c 65 5f 74 65 78 74 20 7b 66 69  et_file_text {fi
0490: 6c 65 6e 61 6d 65 7d 20 7b 73 65 74 20 63 68 20  lename} {set ch 
04a0: 5b 6f 70 65 6e 20 24 66 69 6c 65 6e 61 6d 65 20  [open $filename 
04b0: 72 5d 3b 73 65 74 20 64 61 74 61 20 5b 72 65 61  r];set data [rea
04c0: 64 20 24 63 68 5d 3b 63 6c 6f 73 65 20 24 63 68  d $ch];close $ch
04d0: 3b 72 65 74 75 72 6e 20 24 64 61 74 61 7d 2c 2c  ;return $data},,
04e0: 2c 2c 2c 2c 2c 2c 2c 0a 2c 2c 2c 2c 2c 2c 2c 2c  ,,,,,,,.,,,,,,,,
04f0: 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 22 73 65 74 20  ,,.command,"set 
0500: 74 65 73 74 5f 64 61 74 61 20 22 22 45 78 61 6d  test_data ""Exam
0510: 70 6c 65 20 73 74 72 69 6e 67 20 66 6f 72 20 6d  ple string for m
0520: 65 73 73 61 67 65 20 64 69 67 65 73 74 20 74 65  essage digest te
0530: 73 74 73 2e 5c 6e 22 22 22 2c 2c 2c 2c 2c 2c 2c  sts.\n""",,,,,,,
0540: 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 22 73 65 74 20  ,,.command,"set 
0550: 75 6e 65 6e 63 72 79 70 74 65 64 5f 66 69 6c 65  unencrypted_file
0560: 20 22 22 75 6e 65 6e 63 72 79 70 74 65 64 5f 64   ""unencrypted_d
0570: 61 74 61 2e 64 61 74 22 22 22 2c 2c 2c 2c 2c 2c  ata.dat""",,,,,,
0580: 2c 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 22 73 65 74  ,,,.command,"set
0590: 20 65 6e 63 72 79 70 74 65 64 5f 66 69 6c 65 20   encrypted_file 
05a0: 22 22 65 6e 63 72 79 70 74 65 64 5f 64 61 74 61  ""encrypted_data
05b0: 2e 64 61 74 22 22 22 2c 2c 2c 2c 2c 2c 2c 2c 2c  .dat""",,,,,,,,,
05c0: 0a 63 6f 6d 6d 61 6e 64 2c 22 73 65 74 20 61 6c  .command,"set al
05d0: 74 5f 66 69 6c 65 20 22 22 72 65 73 75 6c 74 5f  t_file ""result_
05e0: 64 61 74 61 2e 64 61 74 22 22 22 2c 2c 2c 2c 2c  data.dat""",,,,,
05f0: 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 22 73 65  ,,,,.command,"se
0600: 74 20 74 65 73 74 5f 6b 65 79 20 22 22 45 78 61  t test_key ""Exa
0610: 6d 70 6c 65 20 6b 65 79 22 22 22 2c 2c 2c 2c 2c  mple key""",,,,,
0620: 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 22 73 65  ,,,,.command,"se
0630: 74 20 74 65 73 74 5f 69 76 20 22 22 45 78 61 6d  t test_iv ""Exam
0640: 70 6c 65 20 69 76 22 22 22 2c 2c 2c 2c 2c 2c 2c  ple iv""",,,,,,,
0650: 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 3a 3a 74 63 6c  ,,.command,::tcl
0660: 74 65 73 74 3a 3a 6d 61 6b 65 46 69 6c 65 20 24  test::makeFile $
0670: 74 65 73 74 5f 64 61 74 61 20 24 75 6e 65 6e 63  test_data $unenc
0680: 72 79 70 74 65 64 5f 66 69 6c 65 2c 2c 2c 2c 2c  rypted_file,,,,,
0690: 2c 2c 2c 2c 0a 20 2c 2c 2c 2c 2c 2c 2c 2c 2c 2c  ,,,,. ,,,,,,,,,,
06a0: 0a 63 6f 6d 6d 61 6e 64 2c 23 20 54 65 73 74 20  .command,# Test 
06b0: 65 6e 63 72 79 70 74 20 64 61 74 61 2c 2c 2c 2c  encrypt data,,,,
06c0: 2c 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 73 65  ,,,,,.command,se
06d0: 74 20 63 69 70 68 65 72 20 61 65 73 2d 31 32 38  t cipher aes-128
06e0: 2d 63 62 63 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f  -cbc,,,,,,,,,.co
06f0: 6d 6d 61 6e 64 2c 22 73 65 74 20 68 65 78 5f 73  mmand,"set hex_s
0700: 74 72 69 6e 67 20 22 22 33 63 65 61 30 33 34 33  tring ""3cea0343
0710: 39 38 64 65 36 34 35 30 37 61 62 62 63 37 62 63  98de64507abbc7bc
0720: 66 36 61 63 62 61 35 35 63 37 30 31 31 31 30 30  f6acba55c7011100
0730: 63 39 30 31 35 63 32 32 62 33 63 39 63 33 33 31  c9015c22b3c9c331
0740: 64 31 38 34 37 39 66 65 64 35 65 35 34 32 63 65  d18479fed5e542ce
0750: 30 32 61 33 62 38 39 61 30 66 37 35 30 64 61 66  02a3b89a0f750daf
0760: 38 65 32 61 34 39 34 65 22 22 22 2c 2c 2c 2c 2c  8e2a494e""",,,,,
0770: 2c 2c 2c 2c 0a 45 6e 63 72 79 70 74 20 44 65 63  ,,,,.Encrypt Dec
0780: 72 79 70 74 20 44 61 74 61 2c 45 6e 63 72 79 70  rypt Data,Encryp
0790: 74 20 61 65 73 2d 31 33 38 2d 63 62 63 2c 2c 2c  t aes-138-cbc,,,
07a0: 62 69 6e 61 72 79 20 65 6e 63 6f 64 65 20 68 65  binary encode he
07b0: 78 20 5b 73 65 74 20 64 61 74 61 20 5b 74 6c 73  x [set data [tls
07c0: 3a 3a 65 6e 63 72 79 70 74 20 2d 63 69 70 68 65  ::encrypt -ciphe
07d0: 72 20 24 63 69 70 68 65 72 20 2d 6b 65 79 20 24  r $cipher -key $
07e0: 74 65 73 74 5f 6b 65 79 20 2d 69 76 20 24 74 65  test_key -iv $te
07f0: 73 74 5f 69 76 20 2d 64 61 74 61 20 24 74 65 73  st_iv -data $tes
0800: 74 5f 64 61 74 61 5d 5d 2c 2c 2c 24 68 65 78 5f  t_data]],,,$hex_
0810: 73 74 72 69 6e 67 2c 2c 2c 0a 45 6e 63 72 79 70  string,,,.Encryp
0820: 74 20 44 65 63 72 79 70 74 20 44 61 74 61 2c 44  t Decrypt Data,D
0830: 65 63 72 79 70 74 20 61 65 73 2d 31 32 38 2d 63  ecrypt aes-128-c
0840: 62 63 2c 2c 2c 74 6c 73 3a 3a 64 65 63 72 79 70  bc,,,tls::decryp
0850: 74 20 2d 63 69 70 68 65 72 20 24 63 69 70 68 65  t -cipher $ciphe
0860: 72 20 2d 6b 65 79 20 24 74 65 73 74 5f 6b 65 79  r -key $test_key
0870: 20 2d 69 76 20 24 74 65 73 74 5f 69 76 20 2d 64   -iv $test_iv -d
0880: 61 74 61 20 24 64 61 74 61 2c 2c 2c 24 74 65 73  ata $data,,,$tes
0890: 74 5f 64 61 74 61 2c 2c 2c 0a 20 2c 2c 2c 2c 2c  t_data,,,. ,,,,,
08a0: 2c 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 23 20  ,,,,,.command,# 
08b0: 54 65 73 74 20 65 6e 63 72 79 70 74 20 66 69 6c  Test encrypt fil
08c0: 65 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 45 6e 63 72 79  e,,,,,,,,,.Encry
08d0: 70 74 20 44 65 63 72 79 70 74 20 46 69 6c 65 2c  pt Decrypt File,
08e0: 45 6e 63 72 79 70 74 20 61 65 73 2d 31 33 38 2d  Encrypt aes-138-
08f0: 63 62 63 2c 2c 2c 74 6c 73 3a 3a 65 6e 63 72 79  cbc,,,tls::encry
0900: 70 74 20 2d 63 69 70 68 65 72 20 24 63 69 70 68  pt -cipher $ciph
0910: 65 72 20 2d 6b 65 79 20 24 74 65 73 74 5f 6b 65  er -key $test_ke
0920: 79 20 2d 69 76 20 24 74 65 73 74 5f 69 76 20 2d  y -iv $test_iv -
0930: 69 6e 66 69 6c 65 20 24 75 6e 65 6e 63 72 79 70  infile $unencryp
0940: 74 65 64 5f 66 69 6c 65 20 2d 6f 75 74 66 69 6c  ted_file -outfil
0950: 65 20 24 65 6e 63 72 79 70 74 65 64 5f 66 69 6c  e $encrypted_fil
0960: 65 3b 67 65 74 5f 66 69 6c 65 5f 68 65 78 20 24  e;get_file_hex $
0970: 65 6e 63 72 79 70 74 65 64 5f 66 69 6c 65 2c 2c  encrypted_file,,
0980: 2c 24 68 65 78 5f 73 74 72 69 6e 67 2c 2c 2c 0a  ,$hex_string,,,.
0990: 45 6e 63 72 79 70 74 20 44 65 63 72 79 70 74 20  Encrypt Decrypt 
09a0: 46 69 6c 65 2c 44 65 63 72 79 70 74 20 61 65 73  File,Decrypt aes
09b0: 2d 31 32 38 2d 63 62 63 2c 2c 2c 74 6c 73 3a 3a  -128-cbc,,,tls::
09c0: 64 65 63 72 79 70 74 20 2d 63 69 70 68 65 72 20  decrypt -cipher 
09d0: 24 63 69 70 68 65 72 20 2d 6b 65 79 20 24 74 65  $cipher -key $te
09e0: 73 74 5f 6b 65 79 20 2d 69 76 20 24 74 65 73 74  st_key -iv $test
09f0: 5f 69 76 20 2d 69 6e 66 69 6c 65 20 24 65 6e 63  _iv -infile $enc
0a00: 72 79 70 74 65 64 5f 66 69 6c 65 20 2d 6f 75 74  rypted_file -out
0a10: 66 69 6c 65 20 24 61 6c 74 5f 66 69 6c 65 3b 67  file $alt_file;g
0a20: 65 74 5f 66 69 6c 65 5f 74 65 78 74 20 24 61 6c  et_file_text $al
0a30: 74 5f 66 69 6c 65 2c 2c 2c 24 74 65 73 74 5f 64  t_file,,,$test_d
0a40: 61 74 61 2c 2c 2c 0a 20 2c 2c 2c 2c 2c 2c 2c 2c  ata,,,. ,,,,,,,,
0a50: 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 23 20 54 65 73  ,,.command,# Tes
0a60: 74 20 65 6e 63 72 79 70 74 20 75 73 69 6e 67 20  t encrypt using 
0a70: 6f 62 6a 65 63 74 20 63 6f 6d 6d 61 6e 64 2c 2c  object command,,
0a80: 2c 2c 2c 2c 2c 2c 2c 0a 45 6e 63 72 79 70 74 20  ,,,,,,,.Encrypt 
0a90: 44 65 63 72 79 70 74 20 43 6f 6d 6d 61 6e 64 2c  Decrypt Command,
0aa0: 45 6e 63 72 79 70 74 20 61 65 73 2d 31 33 38 2d  Encrypt aes-138-
0ab0: 63 62 63 2c 2c 2c 61 63 63 75 6d 75 6c 61 74 65  cbc,,,accumulate
0ac0: 20 24 74 65 73 74 5f 64 61 74 61 20 74 6c 73 3a   $test_data tls:
0ad0: 3a 65 6e 63 72 79 70 74 20 2d 63 69 70 68 65 72  :encrypt -cipher
0ae0: 20 24 63 69 70 68 65 72 20 2d 6b 65 79 20 24 74   $cipher -key $t
0af0: 65 73 74 5f 6b 65 79 20 2d 69 76 20 24 74 65 73  est_key -iv $tes
0b00: 74 5f 69 76 3b 62 69 6e 61 72 79 20 65 6e 63 6f  t_iv;binary enco
0b10: 64 65 20 68 65 78 20 24 3a 3a 64 61 74 2c 2c 2c  de hex $::dat,,,
0b20: 24 68 65 78 5f 73 74 72 69 6e 67 2c 2c 2c 0a 45  $hex_string,,,.E
0b30: 6e 63 72 79 70 74 20 44 65 63 72 79 70 74 20 43  ncrypt Decrypt C
0b40: 6f 6d 6d 61 6e 64 2c 44 65 63 72 79 70 74 20 61  ommand,Decrypt a
0b50: 65 73 2d 31 32 38 2d 63 62 63 2c 2c 2c 61 63 63  es-128-cbc,,,acc
0b60: 75 6d 75 6c 61 74 65 20 24 3a 3a 64 61 74 20 74  umulate $::dat t
0b70: 6c 73 3a 3a 64 65 63 72 79 70 74 20 2d 63 69 70  ls::decrypt -cip
0b80: 68 65 72 20 24 63 69 70 68 65 72 20 2d 6b 65 79  her $cipher -key
0b90: 20 24 74 65 73 74 5f 6b 65 79 20 2d 69 76 20 24   $test_key -iv $
0ba0: 74 65 73 74 5f 69 76 3b 73 65 74 20 3a 3a 64 61  test_iv;set ::da
0bb0: 74 2c 2c 2c 24 74 65 73 74 5f 64 61 74 61 2c 2c  t,,,$test_data,,
0bc0: 2c 0a 20 2c 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f  ,. ,,,,,,,,,,.co
0bd0: 6d 6d 61 6e 64 2c 23 20 54 65 73 74 20 65 6e 63  mmand,# Test enc
0be0: 72 79 70 74 20 75 73 69 6e 67 20 72 65 61 64 20  rypt using read 
0bf0: 63 68 61 6e 6e 65 6c 2c 2c 2c 2c 2c 2c 2c 2c 2c  channel,,,,,,,,,
0c00: 0a 45 6e 63 72 79 70 74 20 44 65 63 72 79 70 74  .Encrypt Decrypt
0c10: 20 43 68 61 6e 6e 65 6c 20 52 65 61 64 2c 45 6e   Channel Read,En
0c20: 63 72 79 70 74 20 61 65 73 2d 31 33 38 2d 63 62  crypt aes-138-cb
0c30: 63 2c 2c 2c 62 69 6e 61 72 79 20 65 6e 63 6f 64  c,,,binary encod
0c40: 65 20 68 65 78 20 5b 72 65 61 64 5f 63 68 61 6e  e hex [read_chan
0c50: 20 24 75 6e 65 6e 63 72 79 70 74 65 64 5f 66 69   $unencrypted_fi
0c60: 6c 65 20 74 6c 73 3a 3a 65 6e 63 72 79 70 74 20  le tls::encrypt 
0c70: 2d 63 69 70 68 65 72 20 24 63 69 70 68 65 72 20  -cipher $cipher 
0c80: 2d 6b 65 79 20 24 74 65 73 74 5f 6b 65 79 20 2d  -key $test_key -
0c90: 69 76 20 24 74 65 73 74 5f 69 76 5d 2c 2c 2c 24  iv $test_iv],,,$
0ca0: 68 65 78 5f 73 74 72 69 6e 67 2c 2c 2c 0a 45 6e  hex_string,,,.En
0cb0: 63 72 79 70 74 20 44 65 63 72 79 70 74 20 43 68  crypt Decrypt Ch
0cc0: 61 6e 6e 65 6c 20 52 65 61 64 2c 44 65 63 72 79  annel Read,Decry
0cd0: 70 74 20 61 65 73 2d 31 33 38 2d 63 62 63 2c 2c  pt aes-138-cbc,,
0ce0: 2c 72 65 61 64 5f 63 68 61 6e 20 24 65 6e 63 72  ,read_chan $encr
0cf0: 79 70 74 65 64 5f 66 69 6c 65 20 74 6c 73 3a 3a  ypted_file tls::
0d00: 64 65 63 72 79 70 74 20 2d 63 69 70 68 65 72 20  decrypt -cipher 
0d10: 24 63 69 70 68 65 72 20 2d 6b 65 79 20 24 74 65  $cipher -key $te
0d20: 73 74 5f 6b 65 79 20 2d 69 76 20 24 74 65 73 74  st_key -iv $test
0d30: 5f 69 76 2c 2c 2c 24 74 65 73 74 5f 64 61 74 61  _iv,,,$test_data
0d40: 2c 2c 2c 0a 20 2c 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a  ,,,. ,,,,,,,,,,.
0d50: 63 6f 6d 6d 61 6e 64 2c 23 20 54 65 73 74 20 65  command,# Test e
0d60: 6e 63 72 79 70 74 20 75 73 69 6e 67 20 77 72 69  ncrypt using wri
0d70: 74 65 20 63 68 61 6e 6e 65 6c 2c 2c 2c 2c 2c 2c  te channel,,,,,,
0d80: 2c 2c 2c 0a 45 6e 63 72 79 70 74 20 44 65 63 72  ,,,.Encrypt Decr
0d90: 79 70 74 20 43 68 61 6e 6e 65 6c 20 57 72 69 74  ypt Channel Writ
0da0: 65 2c 45 6e 63 72 79 70 74 20 61 65 73 2d 31 33  e,Encrypt aes-13
0db0: 38 2d 63 62 63 2c 2c 2c 62 69 6e 61 72 79 20 65  8-cbc,,,binary e
0dc0: 6e 63 6f 64 65 20 68 65 78 20 5b 73 65 74 20 64  ncode hex [set d
0dd0: 61 74 61 20 5b 77 72 69 74 65 5f 63 68 61 6e 20  ata [write_chan 
0de0: 24 65 6e 63 72 79 70 74 65 64 5f 66 69 6c 65 20  $encrypted_file 
0df0: 24 74 65 73 74 5f 64 61 74 61 20 74 6c 73 3a 3a  $test_data tls::
0e00: 65 6e 63 72 79 70 74 20 2d 63 69 70 68 65 72 20  encrypt -cipher 
0e10: 24 63 69 70 68 65 72 20 2d 6b 65 79 20 24 74 65  $cipher -key $te
0e20: 73 74 5f 6b 65 79 20 2d 69 76 20 24 74 65 73 74  st_key -iv $test
0e30: 5f 69 76 5d 5d 2c 2c 2c 24 68 65 78 5f 73 74 72  _iv]],,,$hex_str
0e40: 69 6e 67 2c 2c 2c 0a 45 6e 63 72 79 70 74 20 44  ing,,,.Encrypt D
0e50: 65 63 72 79 70 74 20 43 68 61 6e 6e 65 6c 20 57  ecrypt Channel W
0e60: 72 69 74 65 2c 44 65 63 72 79 70 74 20 61 65 73  rite,Decrypt aes
0e70: 2d 31 33 38 2d 63 62 63 2c 2c 2c 77 72 69 74 65  -138-cbc,,,write
0e80: 5f 63 68 61 6e 20 24 61 6c 74 5f 66 69 6c 65 20  _chan $alt_file 
0e90: 24 64 61 74 61 20 74 6c 73 3a 3a 64 65 63 72 79  $data tls::decry
0ea0: 70 74 20 2d 63 69 70 68 65 72 20 24 63 69 70 68  pt -cipher $ciph
0eb0: 65 72 20 2d 6b 65 79 20 24 74 65 73 74 5f 6b 65  er -key $test_ke
0ec0: 79 20 2d 69 76 20 24 74 65 73 74 5f 69 76 2c 2c  y -iv $test_iv,,
0ed0: 2c 24 74 65 73 74 5f 64 61 74 61 2c 2c 2c 0a 2c  ,$test_data,,,.,
0ee0: 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e  ,,,,,,,,,.comman
0ef0: 64 2c 23 20 43 6c 65 61 6e 75 70 2c 2c 2c 2c 2c  d,# Cleanup,,,,,
0f00: 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 3a 3a 74  ,,,,.command,::t
0f10: 63 6c 74 65 73 74 3a 3a 72 65 6d 6f 76 65 46 69  cltest::removeFi
0f20: 6c 65 20 24 75 6e 65 6e 63 72 79 70 74 65 64 5f  le $unencrypted_
0f30: 66 69 6c 65 2c 2c 2c 2c 2c 2c 2c 2c 2c 0a 63 6f  file,,,,,,,,,.co
0f40: 6d 6d 61 6e 64 2c 3a 3a 74 63 6c 74 65 73 74 3a  mmand,::tcltest:
0f50: 3a 72 65 6d 6f 76 65 46 69 6c 65 20 24 65 6e 63  :removeFile $enc
0f60: 72 79 70 74 65 64 5f 66 69 6c 65 2c 2c 2c 2c 2c  rypted_file,,,,,
0f70: 2c 2c 2c 2c 0a 63 6f 6d 6d 61 6e 64 2c 3a 3a 74  ,,,,.command,::t
0f80: 63 6c 74 65 73 74 3a 3a 72 65 6d 6f 76 65 46 69  cltest::removeFi
0f90: 6c 65 20 24 61 6c 74 5f 66 69 6c 65 2c 2c 2c 2c  le $alt_file,,,,
0fa0: 2c 2c 2c 2c 2c 0a                                ,,,,,.