Artifact
30ef9b5ec20249f68c0e4dd02f4eaf72f98bf8cd6c0d34b2d7edf3983b413369:
0000: 23 20 41 75 74 6f 20 67 65 6e 65 72 61 74 65 64  # Auto generated
0010: 20 74 65 73 74 20 63 61 73 65 73 20 66 6f 72 20   test cases for 
0020: 65 6e 63 72 79 70 74 2e 63 73 76 0a 0a 23 20 4c  encrypt.csv..# L
0030: 6f 61 64 20 54 63 6c 20 54 65 73 74 20 70 61 63  oad Tcl Test pac
0040: 6b 61 67 65 0a 69 66 20 7b 5b 6c 73 65 61 72 63  kage.if {[lsearc
0050: 68 20 5b 6e 61 6d 65 73 70 61 63 65 20 63 68 69  h [namespace chi
0060: 6c 64 72 65 6e 5d 20 3a 3a 74 63 6c 74 65 73 74  ldren] ::tcltest
0070: 5d 20 3d 3d 20 2d 31 7d 20 7b 0a 09 70 61 63 6b  ] == -1} {..pack
0080: 61 67 65 20 72 65 71 75 69 72 65 20 74 63 6c 74  age require tclt
0090: 65 73 74 0a 09 6e 61 6d 65 73 70 61 63 65 20 69  est..namespace i
00a0: 6d 70 6f 72 74 20 3a 3a 74 63 6c 74 65 73 74 3a  mport ::tcltest:
00b0: 3a 2a 0a 7d 0a 0a 73 65 74 20 61 75 74 6f 5f 70  :*.}..set auto_p
00c0: 61 74 68 20 5b 63 6f 6e 63 61 74 20 5b 6c 69 73  ath [concat [lis
00d0: 74 20 5b 66 69 6c 65 20 64 69 72 6e 61 6d 65 20  t [file dirname 
00e0: 5b 66 69 6c 65 20 64 69 72 6e 61 6d 65 20 5b 69  [file dirname [i
00f0: 6e 66 6f 20 73 63 72 69 70 74 5d 5d 5d 5d 20 24  nfo script]]]] $
0100: 61 75 74 6f 5f 70 61 74 68 5d 0a 0a 70 61 63 6b  auto_path]..pack
0110: 61 67 65 20 72 65 71 75 69 72 65 20 74 6c 73 0a  age require tls.
0120: 0a 23 20 48 65 6c 70 65 72 20 66 75 6e 63 74 69  .# Helper functi
0130: 6f 6e 73 20 2d 20 53 65 65 20 63 6f 6d 6d 6f 6e  ons - See common
0140: 2e 74 63 6c 0a 70 72 6f 63 20 72 65 61 64 5f 63  .tcl.proc read_c
0150: 68 61 6e 20 7b 66 69 6c 65 6e 61 6d 65 20 61 72  han {filename ar
0160: 67 73 7d 20 7b 73 65 74 20 63 68 20 5b 6f 70 65  gs} {set ch [ope
0170: 6e 20 24 66 69 6c 65 6e 61 6d 65 20 72 62 5d 3b  n $filename rb];
0180: 73 65 74 20 62 73 69 7a 65 20 5b 66 63 6f 6e 66  set bsize [fconf
0190: 69 67 75 72 65 20 24 63 68 20 2d 62 75 66 66 65  igure $ch -buffe
01a0: 72 73 69 7a 65 5d 3b 73 65 74 20 6e 65 77 20 5b  rsize];set new [
01b0: 7b 2a 7d 24 61 72 67 73 20 2d 63 68 61 6e 20 24  {*}$args -chan $
01c0: 63 68 5d 3b 73 65 74 20 64 61 74 20 22 22 3b 77  ch];set dat "";w
01d0: 68 69 6c 65 20 7b 21 5b 65 6f 66 20 24 6e 65 77  hile {![eof $new
01e0: 5d 7d 20 7b 61 70 70 65 6e 64 20 64 61 74 20 5b  ]} {append dat [
01f0: 72 65 61 64 20 24 6e 65 77 20 24 62 73 69 7a 65  read $new $bsize
0200: 5d 7d 3b 63 6c 6f 73 65 20 24 6e 65 77 3b 72 65  ]};close $new;re
0210: 74 75 72 6e 20 24 64 61 74 7d 0a 70 72 6f 63 20  turn $dat}.proc 
0220: 77 72 69 74 65 5f 63 68 61 6e 20 7b 66 69 6c 65  write_chan {file
0230: 6e 61 6d 65 20 64 61 74 61 20 61 72 67 73 7d 20  name data args} 
0240: 7b 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 77 62 5d 3b 73 65 74 20  ilename wb];set 
0260: 6e 65 77 20 5b 7b 2a 7d 24 61 72 67 73 20 2d 63  new [{*}$args -c
0270: 68 61 6e 20 24 63 68 5d 3b 70 75 74 73 20 2d 6e  han $ch];puts -n
0280: 6f 6e 65 77 6c 69 6e 65 20 24 6e 65 77 20 24 64  onewline $new $d
0290: 61 74 61 3b 66 6c 75 73 68 20 24 6e 65 77 3b 63  ata;flush $new;c
02a0: 6c 6f 73 65 20 24 6e 65 77 3b 73 65 74 20 63 68  lose $new;set ch
02b0: 20 5b 6f 70 65 6e 20 24 66 69 6c 65 6e 61 6d 65   [open $filename
02c0: 20 72 62 5d 3b 73 65 74 20 64 61 74 20 5b 72 65   rb];set dat [re
02d0: 61 64 20 24 63 68 5d 3b 63 6c 6f 73 65 20 24 63  ad $ch];close $c
02e0: 68 3b 72 65 74 75 72 6e 20 24 64 61 74 7d 0a 70  h;return $dat}.p
02f0: 72 6f 63 20 61 63 63 75 6d 75 6c 61 74 65 20 7b  roc accumulate {
0300: 73 74 72 69 6e 67 20 61 72 67 73 7d 20 7b 73 65  string args} {se
0310: 74 20 63 6d 64 20 5b 7b 2a 7d 24 61 72 67 73 20  t cmd [{*}$args 
0320: 2d 63 6f 6d 6d 61 6e 64 20 64 63 6d 64 5d 3b 73  -command dcmd];s
0330: 65 74 20 3a 3a 64 61 74 20 22 22 3b 61 70 70 65  et ::dat "";appe
0340: 6e 64 20 3a 3a 64 61 74 20 5b 24 63 6d 64 20 75  nd ::dat [$cmd u
0350: 70 64 61 74 65 20 5b 73 74 72 69 6e 67 20 72 61  pdate [string ra
0360: 6e 67 65 20 24 73 74 72 69 6e 67 20 30 20 32 30  nge $string 0 20
0370: 5d 5d 3b 61 70 70 65 6e 64 20 3a 3a 64 61 74 20  ]];append ::dat 
0380: 5b 24 63 6d 64 20 75 70 64 61 74 65 20 5b 73 74  [$cmd update [st
0390: 72 69 6e 67 20 72 61 6e 67 65 20 24 73 74 72 69  ring range $stri
03a0: 6e 67 20 32 31 20 65 6e 64 5d 5d 3b 61 70 70 65  ng 21 end]];appe
03b0: 6e 64 20 3a 3a 64 61 74 20 5b 24 63 6d 64 20 66  nd ::dat [$cmd f
03c0: 69 6e 61 6c 69 7a 65 5d 7d 0a 70 72 6f 63 20 67  inalize]}.proc g
03d0: 65 74 5f 66 69 6c 65 5f 68 65 78 20 7b 66 69 6c  et_file_hex {fil
03e0: 65 6e 61 6d 65 7d 20 7b 73 65 74 20 63 68 20 5b  ename} {set ch [
03f0: 6f 70 65 6e 20 24 66 69 6c 65 6e 61 6d 65 20 72  open $filename r
0400: 62 5d 3b 73 65 74 20 64 61 74 61 20 5b 72 65 61  b];set data [rea
0410: 64 20 24 63 68 5d 3b 63 6c 6f 73 65 20 24 63 68  d $ch];close $ch
0420: 3b 72 65 74 75 72 6e 20 5b 62 69 6e 61 72 79 20  ;return [binary 
0430: 65 6e 63 6f 64 65 20 68 65 78 20 24 64 61 74 61  encode hex $data
0440: 5d 7d 0a 70 72 6f 63 20 67 65 74 5f 66 69 6c 65  ]}.proc get_file
0450: 5f 74 65 78 74 20 7b 66 69 6c 65 6e 61 6d 65 7d  _text {filename}
0460: 20 7b 73 65 74 20 63 68 20 5b 6f 70 65 6e 20 24   {set ch [open $
0470: 66 69 6c 65 6e 61 6d 65 20 72 5d 3b 73 65 74 20  filename r];set 
0480: 64 61 74 61 20 5b 72 65 61 64 20 24 63 68 5d 3b  data [read $ch];
0490: 63 6c 6f 73 65 20 24 63 68 3b 72 65 74 75 72 6e  close $ch;return
04a0: 20 24 64 61 74 61 7d 0a 0a 73 65 74 20 74 65 73   $data}..set tes
04b0: 74 5f 64 61 74 61 20 22 45 78 61 6d 70 6c 65 20  t_data "Example 
04c0: 73 74 72 69 6e 67 20 66 6f 72 20 6d 65 73 73 61  string for messa
04d0: 67 65 20 64 69 67 65 73 74 20 74 65 73 74 73 2e  ge digest tests.
04e0: 5c 6e 22 0a 73 65 74 20 75 6e 65 6e 63 72 79 70  \n".set unencryp
04f0: 74 65 64 5f 66 69 6c 65 20 22 75 6e 65 6e 63 72  ted_file "unencr
0500: 79 70 74 65 64 5f 64 61 74 61 2e 64 61 74 22 0a  ypted_data.dat".
0510: 73 65 74 20 65 6e 63 72 79 70 74 65 64 5f 66 69  set encrypted_fi
0520: 6c 65 20 22 65 6e 63 72 79 70 74 65 64 5f 64 61  le "encrypted_da
0530: 74 61 2e 64 61 74 22 0a 73 65 74 20 61 6c 74 5f  ta.dat".set alt_
0540: 66 69 6c 65 20 22 72 65 73 75 6c 74 5f 64 61 74  file "result_dat
0550: 61 2e 64 61 74 22 0a 73 65 74 20 74 65 73 74 5f  a.dat".set test_
0560: 6b 65 79 20 22 45 78 61 6d 70 6c 65 20 6b 65 79  key "Example key
0570: 22 0a 73 65 74 20 74 65 73 74 5f 69 76 20 22 45  ".set test_iv "E
0580: 78 61 6d 70 6c 65 20 69 76 22 0a 3a 3a 74 63 6c  xample iv".::tcl
0590: 74 65 73 74 3a 3a 6d 61 6b 65 46 69 6c 65 20 24  test::makeFile $
05a0: 74 65 73 74 5f 64 61 74 61 20 24 75 6e 65 6e 63  test_data $unenc
05b0: 72 79 70 74 65 64 5f 66 69 6c 65 0a 0a 23 20 54  rypted_file..# T
05c0: 65 73 74 20 65 6e 63 72 79 70 74 20 64 61 74 61  est encrypt data
05d0: 0a 73 65 74 20 63 69 70 68 65 72 20 61 65 73 2d  .set cipher aes-
05e0: 31 32 38 2d 63 62 63 0a 73 65 74 20 68 65 78 5f  128-cbc.set hex_
05f0: 73 74 72 69 6e 67 20 22 33 63 65 61 30 33 34 33  string "3cea0343
0600: 39 38 64 65 36 34 35 30 37 61 62 62 63 37 62 63  98de64507abbc7bc
0610: 66 36 61 63 62 61 35 35 63 37 30 31 31 31 30 30  f6acba55c7011100
0620: 63 39 30 31 35 63 32 32 62 33 63 39 63 33 33 31  c9015c22b3c9c331
0630: 64 31 38 34 37 39 66 65 64 35 65 35 34 32 63 65  d18479fed5e542ce
0640: 30 32 61 33 62 38 39 61 30 66 37 35 30 64 61 66  02a3b89a0f750daf
0650: 38 65 32 61 34 39 34 65 22 0a 0a 0a 74 65 73 74  8e2a494e"...test
0660: 20 45 6e 63 72 79 70 74 5f 44 65 63 72 79 70 74   Encrypt_Decrypt
0670: 5f 44 61 74 61 2d 31 2e 31 20 7b 45 6e 63 72 79  _Data-1.1 {Encry
0680: 70 74 20 61 65 73 2d 31 33 38 2d 63 62 63 7d 20  pt aes-138-cbc} 
0690: 2d 62 6f 64 79 20 7b 0a 09 62 69 6e 61 72 79 20  -body {..binary 
06a0: 65 6e 63 6f 64 65 20 68 65 78 20 5b 73 65 74 20  encode hex [set 
06b0: 64 61 74 61 20 5b 74 6c 73 3a 3a 65 6e 63 72 79  data [tls::encry
06c0: 70 74 20 2d 63 69 70 68 65 72 20 24 63 69 70 68  pt -cipher $ciph
06d0: 65 72 20 2d 6b 65 79 20 24 74 65 73 74 5f 6b 65  er -key $test_ke
06e0: 79 20 2d 69 76 20 24 74 65 73 74 5f 69 76 20 2d  y -iv $test_iv -
06f0: 64 61 74 61 20 24 74 65 73 74 5f 64 61 74 61 5d  data $test_data]
0700: 5d 0a 20 20 20 20 7d 20 2d 72 65 73 75 6c 74 20  ].    } -result 
0710: 24 68 65 78 5f 73 74 72 69 6e 67 0a 0a 74 65 73  $hex_string..tes
0720: 74 20 45 6e 63 72 79 70 74 5f 44 65 63 72 79 70  t Encrypt_Decryp
0730: 74 5f 44 61 74 61 2d 31 2e 32 20 7b 44 65 63 72  t_Data-1.2 {Decr
0740: 79 70 74 20 61 65 73 2d 31 32 38 2d 63 62 63 7d  ypt aes-128-cbc}
0750: 20 2d 62 6f 64 79 20 7b 0a 09 74 6c 73 3a 3a 64   -body {..tls::d
0760: 65 63 72 79 70 74 20 2d 63 69 70 68 65 72 20 24  ecrypt -cipher $
0770: 63 69 70 68 65 72 20 2d 6b 65 79 20 24 74 65 73  cipher -key $tes
0780: 74 5f 6b 65 79 20 2d 69 76 20 24 74 65 73 74 5f  t_key -iv $test_
0790: 69 76 20 2d 64 61 74 61 20 24 64 61 74 61 0a 20  iv -data $data. 
07a0: 20 20 20 7d 20 2d 72 65 73 75 6c 74 20 24 74 65     } -result $te
07b0: 73 74 5f 64 61 74 61 0a 0a 23 20 54 65 73 74 20  st_data..# Test 
07c0: 65 6e 63 72 79 70 74 20 66 69 6c 65 0a 0a 0a 74  encrypt file...t
07d0: 65 73 74 20 45 6e 63 72 79 70 74 5f 44 65 63 72  est Encrypt_Decr
07e0: 79 70 74 5f 46 69 6c 65 2d 32 2e 31 20 7b 45 6e  ypt_File-2.1 {En
07f0: 63 72 79 70 74 20 61 65 73 2d 31 33 38 2d 63 62  crypt aes-138-cb
0800: 63 7d 20 2d 62 6f 64 79 20 7b 0a 09 74 6c 73 3a  c} -body {..tls:
0810: 3a 65 6e 63 72 79 70 74 20 2d 63 69 70 68 65 72  :encrypt -cipher
0820: 20 24 63 69 70 68 65 72 20 2d 6b 65 79 20 24 74   $cipher -key $t
0830: 65 73 74 5f 6b 65 79 20 2d 69 76 20 24 74 65 73  est_key -iv $tes
0840: 74 5f 69 76 20 2d 69 6e 66 69 6c 65 20 24 75 6e  t_iv -infile $un
0850: 65 6e 63 72 79 70 74 65 64 5f 66 69 6c 65 20 2d  encrypted_file -
0860: 6f 75 74 66 69 6c 65 20 24 65 6e 63 72 79 70 74  outfile $encrypt
0870: 65 64 5f 66 69 6c 65 0a 09 67 65 74 5f 66 69 6c  ed_file..get_fil
0880: 65 5f 68 65 78 20 24 65 6e 63 72 79 70 74 65 64  e_hex $encrypted
0890: 5f 66 69 6c 65 0a 20 20 20 20 7d 20 2d 72 65 73  _file.    } -res
08a0: 75 6c 74 20 24 68 65 78 5f 73 74 72 69 6e 67 0a  ult $hex_string.
08b0: 0a 74 65 73 74 20 45 6e 63 72 79 70 74 5f 44 65  .test Encrypt_De
08c0: 63 72 79 70 74 5f 46 69 6c 65 2d 32 2e 32 20 7b  crypt_File-2.2 {
08d0: 44 65 63 72 79 70 74 20 61 65 73 2d 31 32 38 2d  Decrypt aes-128-
08e0: 63 62 63 7d 20 2d 62 6f 64 79 20 7b 0a 09 74 6c  cbc} -body {..tl
08f0: 73 3a 3a 64 65 63 72 79 70 74 20 2d 63 69 70 68  s::decrypt -ciph
0900: 65 72 20 24 63 69 70 68 65 72 20 2d 6b 65 79 20  er $cipher -key 
0910: 24 74 65 73 74 5f 6b 65 79 20 2d 69 76 20 24 74  $test_key -iv $t
0920: 65 73 74 5f 69 76 20 2d 69 6e 66 69 6c 65 20 24  est_iv -infile $
0930: 65 6e 63 72 79 70 74 65 64 5f 66 69 6c 65 20 2d  encrypted_file -
0940: 6f 75 74 66 69 6c 65 20 24 61 6c 74 5f 66 69 6c  outfile $alt_fil
0950: 65 0a 09 67 65 74 5f 66 69 6c 65 5f 74 65 78 74  e..get_file_text
0960: 20 24 61 6c 74 5f 66 69 6c 65 0a 20 20 20 20 7d   $alt_file.    }
0970: 20 2d 72 65 73 75 6c 74 20 24 74 65 73 74 5f 64   -result $test_d
0980: 61 74 61 0a 0a 23 20 54 65 73 74 20 65 6e 63 72  ata..# Test encr
0990: 79 70 74 20 75 73 69 6e 67 20 6f 62 6a 65 63 74  ypt using object
09a0: 20 63 6f 6d 6d 61 6e 64 0a 0a 0a 74 65 73 74 20   command...test 
09b0: 45 6e 63 72 79 70 74 5f 44 65 63 72 79 70 74 5f  Encrypt_Decrypt_
09c0: 43 6f 6d 6d 61 6e 64 2d 33 2e 31 20 7b 45 6e 63  Command-3.1 {Enc
09d0: 72 79 70 74 20 61 65 73 2d 31 33 38 2d 63 62 63  rypt aes-138-cbc
09e0: 7d 20 2d 62 6f 64 79 20 7b 0a 09 61 63 63 75 6d  } -body {..accum
09f0: 75 6c 61 74 65 20 24 74 65 73 74 5f 64 61 74 61  ulate $test_data
0a00: 20 74 6c 73 3a 3a 65 6e 63 72 79 70 74 20 2d 63   tls::encrypt -c
0a10: 69 70 68 65 72 20 24 63 69 70 68 65 72 20 2d 6b  ipher $cipher -k
0a20: 65 79 20 24 74 65 73 74 5f 6b 65 79 20 2d 69 76  ey $test_key -iv
0a30: 20 24 74 65 73 74 5f 69 76 0a 09 62 69 6e 61 72   $test_iv..binar
0a40: 79 20 65 6e 63 6f 64 65 20 68 65 78 20 24 3a 3a  y encode hex $::
0a50: 64 61 74 0a 20 20 20 20 7d 20 2d 72 65 73 75 6c  dat.    } -resul
0a60: 74 20 24 68 65 78 5f 73 74 72 69 6e 67 0a 0a 74  t $hex_string..t
0a70: 65 73 74 20 45 6e 63 72 79 70 74 5f 44 65 63 72  est Encrypt_Decr
0a80: 79 70 74 5f 43 6f 6d 6d 61 6e 64 2d 33 2e 32 20  ypt_Command-3.2 
0a90: 7b 44 65 63 72 79 70 74 20 61 65 73 2d 31 32 38  {Decrypt aes-128
0aa0: 2d 63 62 63 7d 20 2d 62 6f 64 79 20 7b 0a 09 61  -cbc} -body {..a
0ab0: 63 63 75 6d 75 6c 61 74 65 20 24 3a 3a 64 61 74  ccumulate $::dat
0ac0: 20 74 6c 73 3a 3a 64 65 63 72 79 70 74 20 2d 63   tls::decrypt -c
0ad0: 69 70 68 65 72 20 24 63 69 70 68 65 72 20 2d 6b  ipher $cipher -k
0ae0: 65 79 20 24 74 65 73 74 5f 6b 65 79 20 2d 69 76  ey $test_key -iv
0af0: 20 24 74 65 73 74 5f 69 76 0a 09 73 65 74 20 3a   $test_iv..set :
0b00: 3a 64 61 74 0a 20 20 20 20 7d 20 2d 72 65 73 75  :dat.    } -resu
0b10: 6c 74 20 24 74 65 73 74 5f 64 61 74 61 0a 0a 23  lt $test_data..#
0b20: 20 54 65 73 74 20 65 6e 63 72 79 70 74 20 75 73   Test encrypt us
0b30: 69 6e 67 20 72 65 61 64 20 63 68 61 6e 6e 65 6c  ing read channel
0b40: 0a 0a 0a 74 65 73 74 20 45 6e 63 72 79 70 74 5f  ...test Encrypt_
0b50: 44 65 63 72 79 70 74 5f 43 68 61 6e 6e 65 6c 5f  Decrypt_Channel_
0b60: 52 65 61 64 2d 34 2e 31 20 7b 45 6e 63 72 79 70  Read-4.1 {Encryp
0b70: 74 20 61 65 73 2d 31 33 38 2d 63 62 63 7d 20 2d  t aes-138-cbc} -
0b80: 62 6f 64 79 20 7b 0a 09 62 69 6e 61 72 79 20 65  body {..binary e
0b90: 6e 63 6f 64 65 20 68 65 78 20 5b 72 65 61 64 5f  ncode hex [read_
0ba0: 63 68 61 6e 20 24 75 6e 65 6e 63 72 79 70 74 65  chan $unencrypte
0bb0: 64 5f 66 69 6c 65 20 74 6c 73 3a 3a 65 6e 63 72  d_file tls::encr
0bc0: 79 70 74 20 2d 63 69 70 68 65 72 20 24 63 69 70  ypt -cipher $cip
0bd0: 68 65 72 20 2d 6b 65 79 20 24 74 65 73 74 5f 6b  her -key $test_k
0be0: 65 79 20 2d 69 76 20 24 74 65 73 74 5f 69 76 5d  ey -iv $test_iv]
0bf0: 0a 20 20 20 20 7d 20 2d 72 65 73 75 6c 74 20 24  .    } -result $
0c00: 68 65 78 5f 73 74 72 69 6e 67 0a 0a 74 65 73 74  hex_string..test
0c10: 20 45 6e 63 72 79 70 74 5f 44 65 63 72 79 70 74   Encrypt_Decrypt
0c20: 5f 43 68 61 6e 6e 65 6c 5f 52 65 61 64 2d 34 2e  _Channel_Read-4.
0c30: 32 20 7b 44 65 63 72 79 70 74 20 61 65 73 2d 31  2 {Decrypt aes-1
0c40: 33 38 2d 63 62 63 7d 20 2d 62 6f 64 79 20 7b 0a  38-cbc} -body {.
0c50: 09 72 65 61 64 5f 63 68 61 6e 20 24 65 6e 63 72  .read_chan $encr
0c60: 79 70 74 65 64 5f 66 69 6c 65 20 74 6c 73 3a 3a  ypted_file tls::
0c70: 64 65 63 72 79 70 74 20 2d 63 69 70 68 65 72 20  decrypt -cipher 
0c80: 24 63 69 70 68 65 72 20 2d 6b 65 79 20 24 74 65  $cipher -key $te
0c90: 73 74 5f 6b 65 79 20 2d 69 76 20 24 74 65 73 74  st_key -iv $test
0ca0: 5f 69 76 0a 20 20 20 20 7d 20 2d 72 65 73 75 6c  _iv.    } -resul
0cb0: 74 20 24 74 65 73 74 5f 64 61 74 61 0a 0a 23 20  t $test_data..# 
0cc0: 54 65 73 74 20 65 6e 63 72 79 70 74 20 75 73 69  Test encrypt usi
0cd0: 6e 67 20 77 72 69 74 65 20 63 68 61 6e 6e 65 6c  ng write channel
0ce0: 0a 0a 0a 74 65 73 74 20 45 6e 63 72 79 70 74 5f  ...test Encrypt_
0cf0: 44 65 63 72 79 70 74 5f 43 68 61 6e 6e 65 6c 5f  Decrypt_Channel_
0d00: 57 72 69 74 65 2d 35 2e 31 20 7b 45 6e 63 72 79  Write-5.1 {Encry
0d10: 70 74 20 61 65 73 2d 31 33 38 2d 63 62 63 7d 20  pt aes-138-cbc} 
0d20: 2d 62 6f 64 79 20 7b 0a 09 62 69 6e 61 72 79 20  -body {..binary 
0d30: 65 6e 63 6f 64 65 20 68 65 78 20 5b 73 65 74 20  encode hex [set 
0d40: 64 61 74 61 20 5b 77 72 69 74 65 5f 63 68 61 6e  data [write_chan
0d50: 20 24 65 6e 63 72 79 70 74 65 64 5f 66 69 6c 65   $encrypted_file
0d60: 20 24 74 65 73 74 5f 64 61 74 61 20 74 6c 73 3a   $test_data tls:
0d70: 3a 65 6e 63 72 79 70 74 20 2d 63 69 70 68 65 72  :encrypt -cipher
0d80: 20 24 63 69 70 68 65 72 20 2d 6b 65 79 20 24 74   $cipher -key $t
0d90: 65 73 74 5f 6b 65 79 20 2d 69 76 20 24 74 65 73  est_key -iv $tes
0da0: 74 5f 69 76 5d 5d 0a 20 20 20 20 7d 20 2d 72 65  t_iv]].    } -re
0db0: 73 75 6c 74 20 24 68 65 78 5f 73 74 72 69 6e 67  sult $hex_string
0dc0: 0a 0a 74 65 73 74 20 45 6e 63 72 79 70 74 5f 44  ..test Encrypt_D
0dd0: 65 63 72 79 70 74 5f 43 68 61 6e 6e 65 6c 5f 57  ecrypt_Channel_W
0de0: 72 69 74 65 2d 35 2e 32 20 7b 44 65 63 72 79 70  rite-5.2 {Decryp
0df0: 74 20 61 65 73 2d 31 33 38 2d 63 62 63 7d 20 2d  t aes-138-cbc} -
0e00: 62 6f 64 79 20 7b 0a 09 77 72 69 74 65 5f 63 68  body {..write_ch
0e10: 61 6e 20 24 61 6c 74 5f 66 69 6c 65 20 24 64 61  an $alt_file $da
0e20: 74 61 20 74 6c 73 3a 3a 64 65 63 72 79 70 74 20  ta tls::decrypt 
0e30: 2d 63 69 70 68 65 72 20 24 63 69 70 68 65 72 20  -cipher $cipher 
0e40: 2d 6b 65 79 20 24 74 65 73 74 5f 6b 65 79 20 2d  -key $test_key -
0e50: 69 76 20 24 74 65 73 74 5f 69 76 0a 20 20 20 20  iv $test_iv.    
0e60: 7d 20 2d 72 65 73 75 6c 74 20 24 74 65 73 74 5f  } -result $test_
0e70: 64 61 74 61 0a 0a 23 20 43 6c 65 61 6e 75 70 0a  data..# Cleanup.
0e80: 3a 3a 74 63 6c 74 65 73 74 3a 3a 72 65 6d 6f 76  ::tcltest::remov
0e90: 65 46 69 6c 65 20 24 75 6e 65 6e 63 72 79 70 74  eFile $unencrypt
0ea0: 65 64 5f 66 69 6c 65 0a 3a 3a 74 63 6c 74 65 73  ed_file.::tcltes
0eb0: 74 3a 3a 72 65 6d 6f 76 65 46 69 6c 65 20 24 65  t::removeFile $e
0ec0: 6e 63 72 79 70 74 65 64 5f 66 69 6c 65 0a 3a 3a  ncrypted_file.::
0ed0: 74 63 6c 74 65 73 74 3a 3a 72 65 6d 6f 76 65 46  tcltest::removeF
0ee0: 69 6c 65 20 24 61 6c 74 5f 66 69 6c 65 0a 0a 23  ile $alt_file..#
0ef0: 20 43 6c 65 61 6e 75 70 0a 3a 3a 74 63 6c 74 65   Cleanup.::tclte
0f00: 73 74 3a 3a 63 6c 65 61 6e 75 70 54 65 73 74 73  st::cleanupTests
0f10: 0a 72 65 74 75 72 6e 0a                          .return.