Diff

Differences From Artifact [b48cec8c56]:

To Artifact [3eea79ae3e]:


20
21
22
23
24
25
26

27
28
29
30
31
32
33
::tcltest::testConstraint OpenSSL [string match "OpenSSL*" [::tls::version]]
# Helper functions
proc lcompare {list1 list2} {set m "";set u "";foreach i $list1 {if {$i ni $list2} {lappend m $i}};foreach i $list2 {if {$i ni $list1} {lappend u $i}};return [list "missing" $m "unexpected" $u]}
proc exec_get {delim args} {return [split [exec openssl {*}$args] $delim]}
proc exec_get_ciphers {} {set list [list];set data [exec openssl list -cipher-algorithms];foreach line [split $data "\n"] {foreach {cipher null alias} [split [string trim $line]] {lappend list [string tolower $cipher]}};return [lsort -unique $list]}
proc exec_get_digests {} {set list [list];set data [exec openssl dgst -list];foreach line [split $data "\n"] {foreach digest $line {if {[string match "-*" $digest]} {lappend list [string trimleft $digest "-"]}}};return [lsort $list]}
proc list_tolower {list} {set result [list];foreach element $list {lappend result [string tolower $element]};return $result}

# Test list ciphers


test Ciphers_List-1.1 {All} -body {
	lcompare [lsort [exec_get_ciphers]] [list_tolower [lsort [::tls::ciphers]]]
    } -result {missing {rc5 rc5-cbc rc5-cfb rc5-ecb rc5-ofb} unexpected {aes-128-ccm aes-128-gcm aes-192-ccm aes-192-gcm aes-256-ccm aes-256-gcm}}
# Test list ciphers for protocols







>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
::tcltest::testConstraint OpenSSL [string match "OpenSSL*" [::tls::version]]
# Helper functions
proc lcompare {list1 list2} {set m "";set u "";foreach i $list1 {if {$i ni $list2} {lappend m $i}};foreach i $list2 {if {$i ni $list1} {lappend u $i}};return [list "missing" $m "unexpected" $u]}
proc exec_get {delim args} {return [split [exec openssl {*}$args] $delim]}
proc exec_get_ciphers {} {set list [list];set data [exec openssl list -cipher-algorithms];foreach line [split $data "\n"] {foreach {cipher null alias} [split [string trim $line]] {lappend list [string tolower $cipher]}};return [lsort -unique $list]}
proc exec_get_digests {} {set list [list];set data [exec openssl dgst -list];foreach line [split $data "\n"] {foreach digest $line {if {[string match "-*" $digest]} {lappend list [string trimleft $digest "-"]}}};return [lsort $list]}
proc list_tolower {list} {set result [list];foreach element $list {lappend result [string tolower $element]};return $result}
proc read_chan {md filename args} {set ch [open $filename rb];fconfigure $ch -translation binary;set new [tls::digest $md {*}$args -chan $ch];while {![eof $new]} {set result [read $new]};close $new;return $result}
# Test list ciphers


test Ciphers_List-1.1 {All} -body {
	lcompare [lsort [exec_get_ciphers]] [list_tolower [lsort [::tls::ciphers]]]
    } -result {missing {rc5 rc5-cbc rc5-cfb rc5-ecb rc5-ofb} unexpected {aes-128-ccm aes-128-gcm aes-192-ccm aes-192-gcm aes-256-ccm aes-256-gcm}}
# Test list ciphers for protocols
184
185
186
187
188
189
190


























191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
test Digest_File-8.5 {md5 bin} -body {
	string toupper [binary encode hex [tls::digest md5 -bin -file md_data.dat]]
    } -result {CCB1BE2E11D8183E843FF73DA8C6D206}

test Digest_File-8.6 {md5 hex} -body {
	tls::digest md5 -hex -file md_data.dat
    } -result {CCB1BE2E11D8183E843FF73DA8C6D206}


























# Test list protocols


test Protocols-9.1 {All} -body {
	lcompare $protocols [::tls::protocols]
    } -result {missing {ssl2 ssl3} unexpected {}}
# Test show version


test Version-10.1 {All} -body {
	::tls::version
    } -match {glob} -result {*}

test Version-10.2 {OpenSSL} -constraints {OpenSSL} -body {
	::tls::version
    } -match {glob} -result {OpenSSL*}

# Cleanup
::tcltest::cleanupTests
return







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



|





|



|






185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
test Digest_File-8.5 {md5 bin} -body {
	string toupper [binary encode hex [tls::digest md5 -bin -file md_data.dat]]
    } -result {CCB1BE2E11D8183E843FF73DA8C6D206}

test Digest_File-8.6 {md5 hex} -body {
	tls::digest md5 -hex -file md_data.dat
    } -result {CCB1BE2E11D8183E843FF73DA8C6D206}
# Test digest command for channel


test Digest_Chan-9.1 {md4} -body {
	read_chan md4 md_data.dat
    } -result {181CDCF9DB9B6FA8FC0A3BF9C34E29D9}

test Digest_Chan-9.2 {md5} -body {
	read_chan md5 md_data.dat
    } -result {CCB1BE2E11D8183E843FF73DA8C6D206}

test Digest_Chan-9.3 {sha1} -body {
	read_chan sha1 md_data.dat
    } -result {3AEFE840CA492C387E903F15ED6019E7AD833B47}

test Digest_Chan-9.4 {sha256} -body {
	read_chan sha256 md_data.dat
    } -result {B7DFDDEB0314A74FF56A8AC1E3DC57DF09BB52A96DA50F6549EB62CA61A0A491}

test Digest_Chan-9.5 {md5 bin} -body {
	string toupper [binary encode hex [read_chan md5 md_data.dat -bin]]
    } -result {CCB1BE2E11D8183E843FF73DA8C6D206}

test Digest_Chan-9.6 {md5 hex} -body {
	read_chan md5 md_data.dat -hex
    } -result {CCB1BE2E11D8183E843FF73DA8C6D206}
# Test list protocols


test Protocols-10.1 {All} -body {
	lcompare $protocols [::tls::protocols]
    } -result {missing {ssl2 ssl3} unexpected {}}
# Test show version


test Version-11.1 {All} -body {
	::tls::version
    } -match {glob} -result {*}

test Version-11.2 {OpenSSL} -constraints {OpenSSL} -body {
	::tls::version
    } -match {glob} -result {OpenSSL*}

# Cleanup
::tcltest::cleanupTests
return