Artifact
ce8002626b693c0a7c7b65c02bc9f91a96d8e8fab2218a27b0b9dd3eae6a7524:
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 43 6f 6e 73 74 72 61 69 6e 74 73 0a 73 .# Constraints.s
0130: 6f 75 72 63 65 20 63 6f 6d 6d 6f 6e 2e 74 63 6c ource common.tcl
0140: 0a 0a 23 20 48 65 6c 70 65 72 20 66 75 6e 63 74 ..# Helper funct
0150: 69 6f 6e 73 20 2d 20 53 65 65 20 63 6f 6d 6d 6f ions - See commo
0160: 6e 2e 74 63 6c 0a 70 72 6f 63 20 72 65 61 64 5f n.tcl.proc read_
0170: 63 68 61 6e 20 7b 66 69 6c 65 6e 61 6d 65 20 61 chan {filename a
0180: 72 67 73 7d 20 7b 73 65 74 20 63 68 20 5b 6f 70 rgs} {set ch [op
0190: 65 6e 20 24 66 69 6c 65 6e 61 6d 65 20 72 62 5d en $filename rb]
01a0: 3b 73 65 74 20 62 73 69 7a 65 20 5b 66 63 6f 6e ;set bsize [fcon
01b0: 66 69 67 75 72 65 20 24 63 68 20 2d 62 75 66 66 figure $ch -buff
01c0: 65 72 73 69 7a 65 5d 3b 73 65 74 20 6e 65 77 20 ersize];set new
01d0: 5b 7b 2a 7d 24 61 72 67 73 20 2d 63 68 61 6e 20 [{*}$args -chan
01e0: 24 63 68 5d 3b 73 65 74 20 64 61 74 20 22 22 3b $ch];set dat "";
01f0: 77 68 69 6c 65 20 7b 21 5b 65 6f 66 20 24 6e 65 while {![eof $ne
0200: 77 5d 7d 20 7b 61 70 70 65 6e 64 20 64 61 74 20 w]} {append dat
0210: 5b 72 65 61 64 20 24 6e 65 77 20 24 62 73 69 7a [read $new $bsiz
0220: 65 5d 7d 3b 63 6c 6f 73 65 20 24 6e 65 77 3b 72 e]};close $new;r
0230: 65 74 75 72 6e 20 24 64 61 74 7d 0a 70 72 6f 63 eturn $dat}.proc
0240: 20 77 72 69 74 65 5f 63 68 61 6e 20 7b 66 69 6c write_chan {fil
0250: 65 6e 61 6d 65 20 64 61 74 61 20 61 72 67 73 7d ename data args}
0260: 20 7b 73 65 74 20 63 68 20 5b 6f 70 65 6e 20 24 {set ch [open $
0270: 66 69 6c 65 6e 61 6d 65 20 77 62 5d 3b 73 65 74 filename wb];set
0280: 20 6e 65 77 20 5b 7b 2a 7d 24 61 72 67 73 20 2d new [{*}$args -
0290: 63 68 61 6e 20 24 63 68 5d 3b 70 75 74 73 20 2d chan $ch];puts -
02a0: 6e 6f 6e 65 77 6c 69 6e 65 20 24 6e 65 77 20 24 nonewline $new $
02b0: 64 61 74 61 3b 66 6c 75 73 68 20 24 6e 65 77 3b data;flush $new;
02c0: 63 6c 6f 73 65 20 24 6e 65 77 3b 73 65 74 20 63 close $new;set c
02d0: 68 20 5b 6f 70 65 6e 20 24 66 69 6c 65 6e 61 6d h [open $filenam
02e0: 65 20 72 62 5d 3b 73 65 74 20 64 61 74 20 5b 72 e rb];set dat [r
02f0: 65 61 64 20 24 63 68 5d 3b 63 6c 6f 73 65 20 24 ead $ch];close $
0300: 63 68 3b 72 65 74 75 72 6e 20 24 64 61 74 7d 0a ch;return $dat}.
0310: 70 72 6f 63 20 61 63 63 75 6d 75 6c 61 74 65 20 proc accumulate
0320: 7b 73 74 72 69 6e 67 20 61 72 67 73 7d 20 7b 73 {string args} {s
0330: 65 74 20 63 6d 64 20 5b 7b 2a 7d 24 61 72 67 73 et cmd [{*}$args
0340: 20 2d 63 6f 6d 6d 61 6e 64 20 64 63 6d 64 5d 3b -command dcmd];
0350: 73 65 74 20 3a 3a 64 61 74 20 22 22 3b 61 70 70 set ::dat "";app
0360: 65 6e 64 20 3a 3a 64 61 74 20 5b 24 63 6d 64 20 end ::dat [$cmd
0370: 75 70 64 61 74 65 20 5b 73 74 72 69 6e 67 20 72 update [string r
0380: 61 6e 67 65 20 24 73 74 72 69 6e 67 20 30 20 32 ange $string 0 2
0390: 30 5d 5d 3b 61 70 70 65 6e 64 20 3a 3a 64 61 74 0]];append ::dat
03a0: 20 5b 24 63 6d 64 20 75 70 64 61 74 65 20 5b 73 [$cmd update [s
03b0: 74 72 69 6e 67 20 72 61 6e 67 65 20 24 73 74 72 tring range $str
03c0: 69 6e 67 20 32 31 20 65 6e 64 5d 5d 3b 61 70 70 ing 21 end]];app
03d0: 65 6e 64 20 3a 3a 64 61 74 20 5b 24 63 6d 64 20 end ::dat [$cmd
03e0: 66 69 6e 61 6c 69 7a 65 5d 7d 0a 70 72 6f 63 20 finalize]}.proc
03f0: 67 65 74 5f 66 69 6c 65 5f 68 65 78 20 7b 66 69 get_file_hex {fi
0400: 6c 65 6e 61 6d 65 7d 20 7b 73 65 74 20 63 68 20 lename} {set ch
0410: 5b 6f 70 65 6e 20 24 66 69 6c 65 6e 61 6d 65 20 [open $filename
0420: 72 62 5d 3b 73 65 74 20 64 61 74 61 20 5b 72 65 rb];set data [re
0430: 61 64 20 24 63 68 5d 3b 63 6c 6f 73 65 20 24 63 ad $ch];close $c
0440: 68 3b 72 65 74 75 72 6e 20 5b 62 69 6e 61 72 79 h;return [binary
0450: 20 65 6e 63 6f 64 65 20 68 65 78 20 24 64 61 74 encode hex $dat
0460: 61 5d 7d 0a 70 72 6f 63 20 67 65 74 5f 66 69 6c a]}.proc get_fil
0470: 65 5f 74 65 78 74 20 7b 66 69 6c 65 6e 61 6d 65 e_text {filename
0480: 7d 20 7b 73 65 74 20 63 68 20 5b 6f 70 65 6e 20 } {set ch [open
0490: 24 66 69 6c 65 6e 61 6d 65 20 72 5d 3b 73 65 74 $filename r];set
04a0: 20 64 61 74 61 20 5b 72 65 61 64 20 24 63 68 5d data [read $ch]
04b0: 3b 63 6c 6f 73 65 20 24 63 68 3b 72 65 74 75 72 ;close $ch;retur
04c0: 6e 20 24 64 61 74 61 7d 0a 0a 73 65 74 20 74 65 n $data}..set te
04d0: 73 74 5f 64 61 74 61 20 22 45 78 61 6d 70 6c 65 st_data "Example
04e0: 20 73 74 72 69 6e 67 20 66 6f 72 20 6d 65 73 73 string for mess
04f0: 61 67 65 20 64 69 67 65 73 74 20 74 65 73 74 73 age digest tests
0500: 2e 5c 6e 22 0a 73 65 74 20 75 6e 65 6e 63 72 79 .\n".set unencry
0510: 70 74 65 64 5f 66 69 6c 65 20 22 75 6e 65 6e 63 pted_file "unenc
0520: 72 79 70 74 65 64 5f 64 61 74 61 2e 64 61 74 22 rypted_data.dat"
0530: 0a 73 65 74 20 65 6e 63 72 79 70 74 65 64 5f 66 .set encrypted_f
0540: 69 6c 65 20 22 65 6e 63 72 79 70 74 65 64 5f 64 ile "encrypted_d
0550: 61 74 61 2e 64 61 74 22 0a 73 65 74 20 61 6c 74 ata.dat".set alt
0560: 5f 66 69 6c 65 20 22 72 65 73 75 6c 74 5f 64 61 _file "result_da
0570: 74 61 2e 64 61 74 22 0a 73 65 74 20 74 65 73 74 ta.dat".set test
0580: 5f 6b 65 79 20 22 45 78 61 6d 70 6c 65 20 6b 65 _key "Example ke
0590: 79 22 0a 73 65 74 20 74 65 73 74 5f 69 76 20 22 y".set test_iv "
05a0: 45 78 61 6d 70 6c 65 20 69 76 22 0a 3a 3a 74 63 Example iv".::tc
05b0: 6c 74 65 73 74 3a 3a 6d 61 6b 65 46 69 6c 65 20 ltest::makeFile
05c0: 24 74 65 73 74 5f 64 61 74 61 20 24 75 6e 65 6e $test_data $unen
05d0: 63 72 79 70 74 65 64 5f 66 69 6c 65 0a 0a 23 20 crypted_file..#
05e0: 54 65 73 74 20 65 6e 63 72 79 70 74 20 64 61 74 Test encrypt dat
05f0: 61 0a 73 65 74 20 63 69 70 68 65 72 20 61 65 73 a.set cipher aes
0600: 2d 31 32 38 2d 63 62 63 0a 73 65 74 20 68 65 78 -128-cbc.set hex
0610: 5f 73 74 72 69 6e 67 20 22 33 63 65 61 30 33 34 _string "3cea034
0620: 33 39 38 64 65 36 34 35 30 37 61 62 62 63 37 62 398de64507abbc7b
0630: 63 66 36 61 63 62 61 35 35 63 37 30 31 31 31 30 cf6acba55c701110
0640: 30 63 39 30 31 35 63 32 32 62 33 63 39 63 33 33 0c9015c22b3c9c33
0650: 31 64 31 38 34 37 39 66 65 64 35 65 35 34 32 63 1d18479fed5e542c
0660: 65 30 32 61 33 62 38 39 61 30 66 37 35 30 64 61 e02a3b89a0f750da
0670: 66 38 65 32 61 34 39 34 65 22 0a 0a 0a 74 65 73 f8e2a494e"...tes
0680: 74 20 45 6e 63 72 79 70 74 5f 44 65 63 72 79 70 t Encrypt_Decryp
0690: 74 5f 44 61 74 61 2d 31 2e 31 20 7b 45 6e 63 72 t_Data-1.1 {Encr
06a0: 79 70 74 20 61 65 73 2d 31 33 38 2d 63 62 63 7d ypt aes-138-cbc}
06b0: 20 2d 62 6f 64 79 20 7b 0a 09 62 69 6e 61 72 79 -body {..binary
06c0: 20 65 6e 63 6f 64 65 20 68 65 78 20 5b 73 65 74 encode hex [set
06d0: 20 64 61 74 61 20 5b 74 6c 73 3a 3a 65 6e 63 72 data [tls::encr
06e0: 79 70 74 20 2d 63 69 70 68 65 72 20 24 63 69 70 ypt -cipher $cip
06f0: 68 65 72 20 2d 6b 65 79 20 24 74 65 73 74 5f 6b her -key $test_k
0700: 65 79 20 2d 69 76 20 24 74 65 73 74 5f 69 76 20 ey -iv $test_iv
0710: 2d 64 61 74 61 20 24 74 65 73 74 5f 64 61 74 61 -data $test_data
0720: 5d 5d 0a 20 20 20 20 7d 20 2d 72 65 73 75 6c 74 ]]. } -result
0730: 20 24 68 65 78 5f 73 74 72 69 6e 67 0a 0a 74 65 $hex_string..te
0740: 73 74 20 45 6e 63 72 79 70 74 5f 44 65 63 72 79 st Encrypt_Decry
0750: 70 74 5f 44 61 74 61 2d 31 2e 32 20 7b 44 65 63 pt_Data-1.2 {Dec
0760: 72 79 70 74 20 61 65 73 2d 31 32 38 2d 63 62 63 rypt aes-128-cbc
0770: 7d 20 2d 62 6f 64 79 20 7b 0a 09 74 6c 73 3a 3a } -body {..tls::
0780: 64 65 63 72 79 70 74 20 2d 63 69 70 68 65 72 20 decrypt -cipher
0790: 24 63 69 70 68 65 72 20 2d 6b 65 79 20 24 74 65 $cipher -key $te
07a0: 73 74 5f 6b 65 79 20 2d 69 76 20 24 74 65 73 74 st_key -iv $test
07b0: 5f 69 76 20 2d 64 61 74 61 20 24 64 61 74 61 0a _iv -data $data.
07c0: 20 20 20 20 7d 20 2d 72 65 73 75 6c 74 20 24 74 } -result $t
07d0: 65 73 74 5f 64 61 74 61 0a 0a 23 20 54 65 73 74 est_data..# Test
07e0: 20 65 6e 63 72 79 70 74 20 66 69 6c 65 0a 0a 0a encrypt file...
07f0: 74 65 73 74 20 45 6e 63 72 79 70 74 5f 44 65 63 test Encrypt_Dec
0800: 72 79 70 74 5f 46 69 6c 65 2d 32 2e 31 20 7b 45 rypt_File-2.1 {E
0810: 6e 63 72 79 70 74 20 61 65 73 2d 31 33 38 2d 63 ncrypt aes-138-c
0820: 62 63 7d 20 2d 62 6f 64 79 20 7b 0a 09 74 6c 73 bc} -body {..tls
0830: 3a 3a 65 6e 63 72 79 70 74 20 2d 63 69 70 68 65 ::encrypt -ciphe
0840: 72 20 24 63 69 70 68 65 72 20 2d 6b 65 79 20 24 r $cipher -key $
0850: 74 65 73 74 5f 6b 65 79 20 2d 69 76 20 24 74 65 test_key -iv $te
0860: 73 74 5f 69 76 20 2d 69 6e 66 69 6c 65 20 24 75 st_iv -infile $u
0870: 6e 65 6e 63 72 79 70 74 65 64 5f 66 69 6c 65 20 nencrypted_file
0880: 2d 6f 75 74 66 69 6c 65 20 24 65 6e 63 72 79 70 -outfile $encryp
0890: 74 65 64 5f 66 69 6c 65 0a 09 67 65 74 5f 66 69 ted_file..get_fi
08a0: 6c 65 5f 68 65 78 20 24 65 6e 63 72 79 70 74 65 le_hex $encrypte
08b0: 64 5f 66 69 6c 65 0a 20 20 20 20 7d 20 2d 72 65 d_file. } -re
08c0: 73 75 6c 74 20 24 68 65 78 5f 73 74 72 69 6e 67 sult $hex_string
08d0: 0a 0a 74 65 73 74 20 45 6e 63 72 79 70 74 5f 44 ..test Encrypt_D
08e0: 65 63 72 79 70 74 5f 46 69 6c 65 2d 32 2e 32 20 ecrypt_File-2.2
08f0: 7b 44 65 63 72 79 70 74 20 61 65 73 2d 31 32 38 {Decrypt aes-128
0900: 2d 63 62 63 7d 20 2d 62 6f 64 79 20 7b 0a 09 74 -cbc} -body {..t
0910: 6c 73 3a 3a 64 65 63 72 79 70 74 20 2d 63 69 70 ls::decrypt -cip
0920: 68 65 72 20 24 63 69 70 68 65 72 20 2d 6b 65 79 her $cipher -key
0930: 20 24 74 65 73 74 5f 6b 65 79 20 2d 69 76 20 24 $test_key -iv $
0940: 74 65 73 74 5f 69 76 20 2d 69 6e 66 69 6c 65 20 test_iv -infile
0950: 24 65 6e 63 72 79 70 74 65 64 5f 66 69 6c 65 20 $encrypted_file
0960: 2d 6f 75 74 66 69 6c 65 20 24 61 6c 74 5f 66 69 -outfile $alt_fi
0970: 6c 65 0a 09 67 65 74 5f 66 69 6c 65 5f 74 65 78 le..get_file_tex
0980: 74 20 24 61 6c 74 5f 66 69 6c 65 0a 20 20 20 20 t $alt_file.
0990: 7d 20 2d 72 65 73 75 6c 74 20 24 74 65 73 74 5f } -result $test_
09a0: 64 61 74 61 0a 0a 23 20 54 65 73 74 20 65 6e 63 data..# Test enc
09b0: 72 79 70 74 20 75 73 69 6e 67 20 6f 62 6a 65 63 rypt using objec
09c0: 74 20 63 6f 6d 6d 61 6e 64 0a 0a 0a 74 65 73 74 t command...test
09d0: 20 45 6e 63 72 79 70 74 5f 44 65 63 72 79 70 74 Encrypt_Decrypt
09e0: 5f 43 6f 6d 6d 61 6e 64 2d 33 2e 31 20 7b 45 6e _Command-3.1 {En
09f0: 63 72 79 70 74 20 61 65 73 2d 31 33 38 2d 63 62 crypt aes-138-cb
0a00: 63 7d 20 2d 62 6f 64 79 20 7b 0a 09 61 63 63 75 c} -body {..accu
0a10: 6d 75 6c 61 74 65 20 24 74 65 73 74 5f 64 61 74 mulate $test_dat
0a20: 61 20 74 6c 73 3a 3a 65 6e 63 72 79 70 74 20 2d a tls::encrypt -
0a30: 63 69 70 68 65 72 20 24 63 69 70 68 65 72 20 2d cipher $cipher -
0a40: 6b 65 79 20 24 74 65 73 74 5f 6b 65 79 20 2d 69 key $test_key -i
0a50: 76 20 24 74 65 73 74 5f 69 76 0a 09 62 69 6e 61 v $test_iv..bina
0a60: 72 79 20 65 6e 63 6f 64 65 20 68 65 78 20 24 3a ry encode hex $:
0a70: 3a 64 61 74 0a 20 20 20 20 7d 20 2d 72 65 73 75 :dat. } -resu
0a80: 6c 74 20 24 68 65 78 5f 73 74 72 69 6e 67 0a 0a lt $hex_string..
0a90: 74 65 73 74 20 45 6e 63 72 79 70 74 5f 44 65 63 test Encrypt_Dec
0aa0: 72 79 70 74 5f 43 6f 6d 6d 61 6e 64 2d 33 2e 32 rypt_Command-3.2
0ab0: 20 7b 44 65 63 72 79 70 74 20 61 65 73 2d 31 32 {Decrypt aes-12
0ac0: 38 2d 63 62 63 7d 20 2d 62 6f 64 79 20 7b 0a 09 8-cbc} -body {..
0ad0: 61 63 63 75 6d 75 6c 61 74 65 20 24 3a 3a 64 61 accumulate $::da
0ae0: 74 20 74 6c 73 3a 3a 64 65 63 72 79 70 74 20 2d t tls::decrypt -
0af0: 63 69 70 68 65 72 20 24 63 69 70 68 65 72 20 2d cipher $cipher -
0b00: 6b 65 79 20 24 74 65 73 74 5f 6b 65 79 20 2d 69 key $test_key -i
0b10: 76 20 24 74 65 73 74 5f 69 76 0a 09 73 65 74 20 v $test_iv..set
0b20: 3a 3a 64 61 74 0a 20 20 20 20 7d 20 2d 72 65 73 ::dat. } -res
0b30: 75 6c 74 20 24 74 65 73 74 5f 64 61 74 61 0a 0a ult $test_data..
0b40: 23 20 54 65 73 74 20 65 6e 63 72 79 70 74 20 75 # Test encrypt u
0b50: 73 69 6e 67 20 72 65 61 64 20 63 68 61 6e 6e 65 sing read channe
0b60: 6c 0a 0a 0a 74 65 73 74 20 45 6e 63 72 79 70 74 l...test Encrypt
0b70: 5f 44 65 63 72 79 70 74 5f 43 68 61 6e 6e 65 6c _Decrypt_Channel
0b80: 5f 52 65 61 64 2d 34 2e 31 20 7b 45 6e 63 72 79 _Read-4.1 {Encry
0b90: 70 74 20 61 65 73 2d 31 33 38 2d 63 62 63 7d 20 pt aes-138-cbc}
0ba0: 2d 62 6f 64 79 20 7b 0a 09 62 69 6e 61 72 79 20 -body {..binary
0bb0: 65 6e 63 6f 64 65 20 68 65 78 20 5b 72 65 61 64 encode hex [read
0bc0: 5f 63 68 61 6e 20 24 75 6e 65 6e 63 72 79 70 74 _chan $unencrypt
0bd0: 65 64 5f 66 69 6c 65 20 74 6c 73 3a 3a 65 6e 63 ed_file tls::enc
0be0: 72 79 70 74 20 2d 63 69 70 68 65 72 20 24 63 69 rypt -cipher $ci
0bf0: 70 68 65 72 20 2d 6b 65 79 20 24 74 65 73 74 5f pher -key $test_
0c00: 6b 65 79 20 2d 69 76 20 24 74 65 73 74 5f 69 76 key -iv $test_iv
0c10: 5d 0a 20 20 20 20 7d 20 2d 72 65 73 75 6c 74 20 ]. } -result
0c20: 24 68 65 78 5f 73 74 72 69 6e 67 0a 0a 74 65 73 $hex_string..tes
0c30: 74 20 45 6e 63 72 79 70 74 5f 44 65 63 72 79 70 t Encrypt_Decryp
0c40: 74 5f 43 68 61 6e 6e 65 6c 5f 52 65 61 64 2d 34 t_Channel_Read-4
0c50: 2e 32 20 7b 44 65 63 72 79 70 74 20 61 65 73 2d .2 {Decrypt aes-
0c60: 31 33 38 2d 63 62 63 7d 20 2d 62 6f 64 79 20 7b 138-cbc} -body {
0c70: 0a 09 72 65 61 64 5f 63 68 61 6e 20 24 65 6e 63 ..read_chan $enc
0c80: 72 79 70 74 65 64 5f 66 69 6c 65 20 74 6c 73 3a rypted_file tls:
0c90: 3a 64 65 63 72 79 70 74 20 2d 63 69 70 68 65 72 :decrypt -cipher
0ca0: 20 24 63 69 70 68 65 72 20 2d 6b 65 79 20 24 74 $cipher -key $t
0cb0: 65 73 74 5f 6b 65 79 20 2d 69 76 20 24 74 65 73 est_key -iv $tes
0cc0: 74 5f 69 76 0a 20 20 20 20 7d 20 2d 72 65 73 75 t_iv. } -resu
0cd0: 6c 74 20 24 74 65 73 74 5f 64 61 74 61 0a 0a 23 lt $test_data..#
0ce0: 20 54 65 73 74 20 65 6e 63 72 79 70 74 20 75 73 Test encrypt us
0cf0: 69 6e 67 20 77 72 69 74 65 20 63 68 61 6e 6e 65 ing write channe
0d00: 6c 0a 0a 0a 74 65 73 74 20 45 6e 63 72 79 70 74 l...test Encrypt
0d10: 5f 44 65 63 72 79 70 74 5f 43 68 61 6e 6e 65 6c _Decrypt_Channel
0d20: 5f 57 72 69 74 65 2d 35 2e 31 20 7b 45 6e 63 72 _Write-5.1 {Encr
0d30: 79 70 74 20 61 65 73 2d 31 33 38 2d 63 62 63 7d ypt aes-138-cbc}
0d40: 20 2d 62 6f 64 79 20 7b 0a 09 62 69 6e 61 72 79 -body {..binary
0d50: 20 65 6e 63 6f 64 65 20 68 65 78 20 5b 73 65 74 encode hex [set
0d60: 20 64 61 74 61 20 5b 77 72 69 74 65 5f 63 68 61 data [write_cha
0d70: 6e 20 24 65 6e 63 72 79 70 74 65 64 5f 66 69 6c n $encrypted_fil
0d80: 65 20 24 74 65 73 74 5f 64 61 74 61 20 74 6c 73 e $test_data tls
0d90: 3a 3a 65 6e 63 72 79 70 74 20 2d 63 69 70 68 65 ::encrypt -ciphe
0da0: 72 20 24 63 69 70 68 65 72 20 2d 6b 65 79 20 24 r $cipher -key $
0db0: 74 65 73 74 5f 6b 65 79 20 2d 69 76 20 24 74 65 test_key -iv $te
0dc0: 73 74 5f 69 76 5d 5d 0a 20 20 20 20 7d 20 2d 72 st_iv]]. } -r
0dd0: 65 73 75 6c 74 20 24 68 65 78 5f 73 74 72 69 6e esult $hex_strin
0de0: 67 0a 0a 74 65 73 74 20 45 6e 63 72 79 70 74 5f g..test Encrypt_
0df0: 44 65 63 72 79 70 74 5f 43 68 61 6e 6e 65 6c 5f Decrypt_Channel_
0e00: 57 72 69 74 65 2d 35 2e 32 20 7b 44 65 63 72 79 Write-5.2 {Decry
0e10: 70 74 20 61 65 73 2d 31 33 38 2d 63 62 63 7d 20 pt aes-138-cbc}
0e20: 2d 62 6f 64 79 20 7b 0a 09 77 72 69 74 65 5f 63 -body {..write_c
0e30: 68 61 6e 20 24 61 6c 74 5f 66 69 6c 65 20 24 64 han $alt_file $d
0e40: 61 74 61 20 74 6c 73 3a 3a 64 65 63 72 79 70 74 ata tls::decrypt
0e50: 20 2d 63 69 70 68 65 72 20 24 63 69 70 68 65 72 -cipher $cipher
0e60: 20 2d 6b 65 79 20 24 74 65 73 74 5f 6b 65 79 20 -key $test_key
0e70: 2d 69 76 20 24 74 65 73 74 5f 69 76 0a 20 20 20 -iv $test_iv.
0e80: 20 7d 20 2d 72 65 73 75 6c 74 20 24 74 65 73 74 } -result $test
0e90: 5f 64 61 74 61 0a 0a 23 20 43 6c 65 61 6e 75 70 _data..# Cleanup
0ea0: 0a 3a 3a 74 63 6c 74 65 73 74 3a 3a 72 65 6d 6f .::tcltest::remo
0eb0: 76 65 46 69 6c 65 20 24 75 6e 65 6e 63 72 79 70 veFile $unencryp
0ec0: 74 65 64 5f 66 69 6c 65 0a 3a 3a 74 63 6c 74 65 ted_file.::tclte
0ed0: 73 74 3a 3a 72 65 6d 6f 76 65 46 69 6c 65 20 24 st::removeFile $
0ee0: 65 6e 63 72 79 70 74 65 64 5f 66 69 6c 65 0a 3a encrypted_file.:
0ef0: 3a 74 63 6c 74 65 73 74 3a 3a 72 65 6d 6f 76 65 :tcltest::remove
0f00: 46 69 6c 65 20 24 61 6c 74 5f 66 69 6c 65 0a 0a File $alt_file..
0f10: 23 20 43 6c 65 61 6e 75 70 0a 3a 3a 74 63 6c 74 # Cleanup.::tclt
0f20: 65 73 74 3a 3a 63 6c 65 61 6e 75 70 54 65 73 74 est::cleanupTest
0f30: 73 0a 72 65 74 75 72 6e 0a s.return.