Diff

Differences From Artifact [dcf06432bd]:

To Artifact [dae86e37f5]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#
# Test Vectors
#

#
# Create test case and output to test file
#
proc do_test {group tail file_num tc digest params} {
    array set config [list Msg "" Repeat 1]
    array set config $params
    set name name

    # Test info
    set line [format "tcltest::test %s-%d.%d {%s}" $group $file_num $tc $tail]
    append line " \\\n\t"

    # Test constraints
    append line [format "-constraints %s" $digest]
    append line " \\\n\t"

    # Test setup
    set is_hex [expr {[string index $config(Msg) 0] ne "\""}]
    if {[info exists config(Len)] && $config(Len) == 0} {
	set data {""}
	set is_hex 0










<






|







1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
# Test Vectors
#

#
# Create test case and output to test file
#
proc do_test {group tail file_num tc digest params} {
    array set config [list Msg "" Repeat 1]
    array set config $params


    # Test info
    set line [format "tcltest::test %s-%d.%d {%s}" $group $file_num $tc $tail]
    append line " \\\n\t"

    # Test constraints
    append line [format "-constraints %s" [string map [list "-" "_"] $digest]]
    append line " \\\n\t"

    # Test setup
    set is_hex [expr {[string index $config(Msg) 0] ne "\""}]
    if {[info exists config(Len)] && $config(Len) == 0} {
	set data {""}
	set is_hex 0
43
44
45
46
47
48
49

50
51
52
53
54
55
56

    # Test cleanup

    # Test result
    set result ""
    foreach key [list MD Mac Output] {
	if {[info exists config($key)]} {

	    set result $config($key)
	}
    }
    
    append line [format {-match exact -result %s} $result]

    # Return codes







>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

    # Test cleanup

    # Test result
    set result ""
    foreach key [list MD Mac Output] {
	if {[info exists config($key)]} {
# For SHAKE XOF, need to truncate to config(Len) size/8 (bits -> bytes)
	    set result $config($key)
	}
    }
    
    append line [format {-match exact -result %s} $result]

    # Return codes
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
    set digest [string map [list LongMsg "" ShortMsg "" Monte "" "_" "-"] $tail]
    set params [list]

    # Add config info
    puts $out [format "# Auto generated from \"%s\"" [file tail $filename]]
    puts $out "package require tls"
    puts $out "package require tcltest\n"
    puts $out [format "tcltest::testConstraint %s %s" $digest \
	[format {[expr {[lsearch -nocase [tls::digests] %s] > -1}]} $digest]]
    puts $out ""

    # Process file
    while {![eof $ch]} {
	gets $ch line
	set line [string trim $line]







|







79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
    set digest [string map [list LongMsg "" ShortMsg "" Monte "" "_" "-"] $tail]
    set params [list]

    # Add config info
    puts $out [format "# Auto generated from \"%s\"" [file tail $filename]]
    puts $out "package require tls"
    puts $out "package require tcltest\n"
    puts $out [format "tcltest::testConstraint %s %s" [string map [list "-" "_"] $digest] \
	[format {[expr {[lsearch -nocase [tls::digests] %s] > -1}]} $digest]]
    puts $out ""

    # Process file
    while {![eof $ch]} {
	gets $ch line
	set line [string trim $line]
119
120
121
122
123
124
125



126
127
128
129
130
131
132
    }

    # Handle last test case
    if {[llength $params] > 0} {
	puts $out [do_test $group $tail $file_num [incr tc] $digest $params]
	puts $out ""
    }



    close $ch
    close $out
}

#
# Read all config files in directory
#







>
>
>







119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
    }

    # Handle last test case
    if {[llength $params] > 0} {
	puts $out [do_test $group $tail $file_num [incr tc] $digest $params]
	puts $out ""
    }
    
    # Cleanup
    puts $out "# Cleanup\n::tcltest::cleanupTests\nreturn"
    close $ch
    close $out
}

#
# Read all config files in directory
#