Check-in [2922a56dc5]
Overview
Comment:Added test suite for encrypt and decrypt commands
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | crypto
Files: files | file ages | folders
SHA3-256: 2922a56dc5a61ce06aea9effdbb1d6d71087c4834d756ebcea7c1ea56c1e164f
User & Date: bohagan on 2023-12-03 04:52:47
Other Links: branch diff | manifest | tags
Context
2023-12-03
05:44
Updated documentation for encrypt and decrypt commands check-in: 193afd38ea user: bohagan tags: crypto
04:52
Added test suite for encrypt and decrypt commands check-in: 2922a56dc5 user: bohagan tags: crypto
02:24
Added function to encrypt and decrypt using I/O channel check-in: c3fb3a49db user: bohagan tags: crypto
Changes

Modified tests/digest.test from [b15fefa043] to [fa6ff50353].

10
11
12
13
14
15
16
17

18
19
20
21
22
23
24

25
26
27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42
43
44
45
10
11
12
13
14
15
16

17







18










19




20
21
22
23
24
25
26







-
+
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-








package require tls

# Constraints
source common.tcl

# Helper functions - See common.tcl
proc digest_read_chan {cmd filename args} {
proc digest_read_chan {cmd filename args} {;set ch [open $filename rb];set bsize [fconfigure $ch -buffersize];set new [$cmd {*}$args -chan $ch];while {![eof $new]} {set md [read $new $bsize]};close $new;return $md}
	set ch [open $filename rb]
	set bsize [fconfigure $ch -buffersize]
	set new [$cmd {*}$args -chan $ch]
	while {![eof $new]} {set md [read $new $bsize]}
	close $new
	return $md}
proc digest_write_chan {cmd filename data args} {
proc digest_write_chan {cmd filename data args} {;set ch [open $filename wb];set new [$cmd {*}$args -chan $ch];puts -nonewline $new $data;flush $new;close $new;set ch [open $filename rb];set md [read $ch];close $ch;return $md}
	set ch [open $filename wb]
	set new [$cmd {*}$args -chan $ch]
	puts -nonewline $new $data
	flush $new
	close $new
	set ch [open $filename rb]
	set md [read $ch]
	close $ch
	return $md}
proc digest_accumulate {string args} {
proc digest_accumulate {string args} {;set cmd [{*}$args -command dcmd]; $cmd update [string range $string 0 20];$cmd update [string range $string 21 end];return [$cmd finalize]}
	set cmd [{*}$args -command dcmd]
	 $cmd update [string range $string 0 20]
	$cmd update [string range $string 21 end]
	return [$cmd finalize]}

set test_data "Example string for message digest tests.\n"
set test_file "md_data.dat"
set test_alt_file "md_alt_data.dat"
set test_key "Example key"
::tcltest::makeFile $test_data $test_file

Added tests/encrypt.csv version [4af8c409bf].

Added tests/encrypt.test version [ce8002626b].

Modified tests/info.test from [a2f4e9e8c8] to [52471437c8].

13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
28

29
30
31
32

33

34
35

36
37
38
39
40
41
42
43
44
13
14
15
16
17
18
19

20




21



22




23

24
25

26


27
28
29
30
31
32
33







-
+
-
-
-
-

-
-
-
+
-
-
-
-
+
-
+

-
+
-
-







# Make sure path includes location of OpenSSL executable
if {[info exists ::env(OPENSSL)]} {set ::env(path) [string cat [file join $::env(OPENSSL) bin] ";" $::env(path)]}

# Constraints
source common.tcl

# Helper functions
proc lcompare {list1 list2} {set m ""
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]}
	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]}}
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]}
	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 "-"]}}}
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]}
	return [lsort $list]}
proc exec_get_pks {} {set list [list];set data [exec openssl list -public-key-methods];foreach line [split $data "\n"] {if {![string match "*Type:*" $line]} {lappend list [string trim $line]}};return $list}
proc exec_get_macs {} {return [list cmac hmac]}
proc list_tolower {list} {set result [list]
proc list_tolower {list} {set result [list];foreach element $list {lappend result [string tolower $element]};return $result}
	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}}

Modified tests/make_test_files.tcl from [fcabf4c415] to [e265399d3c].

70
71
72
73
74
75
76

77




78
79
80
81
82
83
84
70
71
72
73
74
75
76
77

78
79
80
81
82
83
84
85
86
87
88







+
-
+
+
+
+







		if {$group ne $prev} {
		    incr test
		    set prev $group
		    puts $out ""
		}

		# Test case
		if {[string index $name 0] ne {$}} {
		set buffer [format "\ntest %s-%d.%d {%s}" $group $test [incr cases($group)] $name]
		    set buffer [format "\ntest %s-%d.%d {%s}" $group $test [incr cases($group)] $name]
		} else {
		    set buffer [format "\ntest %s-%d.%d %s" $group $test [incr cases($group)] $name]
		}
		foreach opt [list -constraints -setup -body -cleanup -match -result -output -errorOutput -returnCodes] {
		    set cmd [string trim [set [string trimleft $opt "-"]]]
		    if {$cmd ne ""} {
			if {$opt in [list -setup -body -cleanup]} {
			    append buffer " " $opt " \{\n"
			    foreach line [split $cmd ";"] {
				append buffer \t [string trim $line] \n