# Group,Name,Constraints,Setup,Body,Cleanup,Match,Result,Output,Error Output,Return Codes
command,package require tls,,,,,,,,,
,,,,,,,,,,
command,# Helper functions - See common.tcl,,,,,,,,,
command,"proc read_chan {filename args} {
set ch [open $filename rb]
set bsize [fconfigure $ch -buffersize]
set new [{*}$args -chan $ch]
set dat """"
while {![eof $new]} {
append dat [read $new $bsize]
}
close $new
return $dat
}
",,,,,,,,,
command,"proc write_chan {filename data args} {
set ch [open $filename wb]
set new [{*}$args -chan $ch]
puts -nonewline $new $data
flush $new
close $new
set ch [open $filename rb]
set dat [read $ch]
close $ch
return $dat
}
",,,,,,,,,
command,"proc accumulate {string args} {
set cmd [{*}$args -command dcmd]
set ::dat """"
append ::dat [$cmd update [string range $string 0 20]]
append ::dat [$cmd update [string range $string 21 end]]
append ::dat [$cmd finalize]
}
",,,,,,,,
command,"proc get_file_hex {filename} {
set ch [open $filename rb]
set data [read $ch]
close $ch
return [binary encode hex $data]
}
",,,,,,,,,
command,"proc get_file_text {filename} {
set ch [open $filename r]
set data [read $ch]
close $ch
return $data
}
",,,,,,,,,
,,,,,,,,,,
command,"set test_data ""Example string for message digest tests.\n""",,,,,,,,,
command,"set unencrypted_file ""unencrypted_data.dat""",,,,,,,,,
command,"set encrypted_file ""encrypted_data.dat""",,,,,,,,,
command,"set alt_file ""result_data.dat""",,,,,,,,,
command,"set test_key ""Example key""",,,,,,,,,
command,"set test_iv ""Example iv""",,,,,,,,,
command,::tcltest::makeFile $test_data $unencrypted_file,,,,,,,,,
,,,,,,,,,,
command,# Test encrypt data,,,,,,,,,
command,set cipher aes-128-cbc,,,,,,,,,
command,"set hex_string ""3cea034398de64507abbc7bcf6acba55c7011100c9015c22b3c9c331d18479fed5e542ce02a3b89a0f750daf8e2a494e""",,,,,,,,,
Encrypt Decrypt Data,Encrypt aes-138-cbc,,,binary encode hex [set data [tls::encrypt -cipher $cipher -key $test_key -iv $test_iv -data $test_data]],,,$hex_string,,,
Encrypt Decrypt Data,Decrypt aes-128-cbc,,,tls::decrypt -cipher $cipher -key $test_key -iv $test_iv -data $data,,,$test_data,,,
,,,,,,,,,,
command,# Test encrypt file,,,,,,,,,
Encrypt Decrypt File,Encrypt aes-138-cbc,,,tls::encrypt -cipher $cipher -key $test_key -iv $test_iv -infile $unencrypted_file -outfile $encrypted_file;get_file_hex $encrypted_file,,,$hex_string,,,
Encrypt Decrypt File,Decrypt aes-128-cbc,,,tls::decrypt -cipher $cipher -key $test_key -iv $test_iv -infile $encrypted_file -outfile $alt_file;get_file_text $alt_file,,,$test_data,,,
,,,,,,,,,,
command,# Test encrypt using object command,,,,,,,,,
Encrypt Decrypt Command,Encrypt aes-138-cbc,,,accumulate $test_data tls::encrypt -cipher $cipher -key $test_key -iv $test_iv;binary encode hex $::dat,,,$hex_string,,,
Encrypt Decrypt Command,Decrypt aes-128-cbc,,,accumulate $::dat tls::decrypt -cipher $cipher -key $test_key -iv $test_iv;set ::dat,,,$test_data,,,
,,,,,,,,,,
command,# Test encrypt using read channel,,,,,,,,,
Encrypt Decrypt Channel Read,Encrypt aes-138-cbc,,,binary encode hex [read_chan $unencrypted_file tls::encrypt -cipher $cipher -key $test_key -iv $test_iv],,,$hex_string,,,
Encrypt Decrypt Channel Read,Decrypt aes-138-cbc,,,read_chan $encrypted_file tls::decrypt -cipher $cipher -key $test_key -iv $test_iv,,,$test_data,,,
,,,,,,,,,,
command,# Test encrypt using write channel,,,,,,,,,
Encrypt Decrypt Channel Write,Encrypt aes-138-cbc,,,binary encode hex [set data [write_chan $encrypted_file $test_data tls::encrypt -cipher $cipher -key $test_key -iv $test_iv]],,,$hex_string,,,
Encrypt Decrypt Channel Write,Decrypt aes-138-cbc,,,write_chan $alt_file $data tls::decrypt -cipher $cipher -key $test_key -iv $test_iv,,,$test_data,,,
,,,,,,,,,,
command,# Cleanup,,,,,,,,,
command,::tcltest::removeFile $unencrypted_file,,,,,,,,,
command,::tcltest::removeFile $encrypted_file,,,,,,,,,
command,::tcltest::removeFile $alt_file,,,,,,,,,