Check-in [c12c859d2f]
Overview
Comment:Added SM4 cipher test vectors
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | crypto
Files: files | file ages | folders
SHA3-256: c12c859d2f5e321c499caed00a39b2c2929257615e295da9bf164526c3c36cfe
User & Date: bohagan on 2024-04-09 01:07:25
Other Links: branch diff | manifest | tags
Context
2024-04-09
03:21
Added remaining Camellia cipher test vectors check-in: 51d59fd360 user: bohagan tags: crypto
01:07
Added SM4 cipher test vectors check-in: c12c859d2f user: bohagan tags: crypto
2024-04-08
21:30
Added ARIA cipher test vectors check-in: 2a6486178c user: bohagan tags: crypto
Changes

Added tests/test_vectors/Symetric_Block/SM4-CBC.test version [fa1ce880f1].

Added tests/test_vectors/Symetric_Block/SM4-CBC.txt version [29b8a5369c].

Added tests/test_vectors/Symetric_Block/SM4-CFB.test version [29cccb3138].

Added tests/test_vectors/Symetric_Block/SM4-CFB.txt version [52e155fa40].

Added tests/test_vectors/Symetric_Block/SM4-CTR.test version [ce5732b46d].

Added tests/test_vectors/Symetric_Block/SM4-CTR.txt version [6db0a51cf6].

Added tests/test_vectors/Symetric_Block/SM4-ECB.test version [1240f8c454].

Added tests/test_vectors/Symetric_Block/SM4-ECB.txt version [f13eb5f686].

Added tests/test_vectors/Symetric_Block/SM4-OFB.test version [59f4805856].

Added tests/test_vectors/Symetric_Block/SM4-OFB.txt version [5aa9f2a666].

Added tests/test_vectors/Symetric_Block/SM4.test version [51ff79a1ea].

Added tests/test_vectors/Symetric_Block/SM4.txt version [a892501bc8].

Modified tests/test_vectors/Symetric_Block/make_test.tcl from [79b8785f12] to [b4dbcd9fd1].

16
17
18
19
20
21
22
23

24
25
26
27
28
29
30
16
17
18
19
20
21
22

23
24
25
26
27
28
29
30







-
+







    return $data
}

#
# Create test case and output to test file
#
proc do_test {group cipher test_num tc params fn} {
    array set config [list repeat 1]
    array set config [list iterations 1 repeat 1]
    array set config $params

    # Test info
    set line [format "tcltest::test %s-%d.%d {%s %s} \\\n\t" $group $test_num $tc [string totitle $fn] $cipher]

    # Test constraints
    append line [format "-constraints %s \\\n\t" [string map [list "-" "_"] $cipher]]
42
43
44
45
46
47
48

49




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

50
51
52
53
54
55
56
57
58
59
60







+
-
+
+
+
+








    # Add test parameters
    foreach {param names type} [list -key [list key] s -iv [list iv nonce] s -data $list1 s] {
	foreach name $names {
	    if {[info exists config($name)]} {
		set data [get_value $type $config($name)]
		if {$data ne ""} {
		    if {$param ne "-data" || $config(iterations) == 1} {
		    append cmd " " $param " " $data " \\\n\t\t"
			append cmd " " $param " " $data " \\\n\t\t"
		    } else {
			set cmd [string cat "set data " $data ";for \{set i 0\} \{\$i < " $config(iterations) "\} \{incr i\} \{set data \[" $cmd " " $param " \$data\]\};set data"]
		    }
		}
		break
	    }
	}
    }
    append line [format {-body {binary encode hex [%s]}} [string trimright $cmd " \\\n\t"]]
    append line " \\\n\t"
154
155
156
157
158
159
160
161

162
163
164
165
166
167
168
169
158
159
160
161
162
163
164

165
166
167
168
169
170
171
172
173







-
+








    foreach filename [glob -directory $path *.txt] {
	puts [format "Processing %s" $filename]
	set tail [file tail $filename]
	if {[string match -nocase "Readme.txt" $tail]} {
	    continue
	}

	set cipher [file rootname [file tail $filename]]
	set cipher [string trim [file rootname [file tail $filename]]]
	set id [format "%s_%s" $group $cipher]
	set test_num [incr test_ids($id)]
	parse $id $filename $test_num $cipher
    }
}

main [pwd]
exit