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