Overview
Comment: | Updated SHAKE128 and SHAKE256 test cases |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | crypto |
Files: | files | file ages | folders |
SHA3-256: |
c0f29458a6bfa4f4a80b2e76caebc735 |
User & Date: | bohagan on 2024-03-14 00:30:32 |
Other Links: | branch diff | manifest | tags |
Context
2024-03-14
| ||
01:09 | Updated documentation to add XOF use of -length arg check-in: 5d50e20efb user: bohagan tags: crypto | |
00:30 | Updated SHAKE128 and SHAKE256 test cases check-in: c0f29458a6 user: bohagan tags: crypto | |
2024-03-13
| ||
23:07 | Finished SHAKE128 and SHAKE256 XOF hash functions by adding optional -length arg to set output length. check-in: 59eac2fc22 user: bohagan tags: crypto | |
Changes
Modified tests/digest.csv from [f8d5498d86] to [62013deed8].
︙ | ︙ | |||
31 32 33 34 35 36 37 | ",,,,,,,,, command,"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] } | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | ",,,,,,,,, command,"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] } ",,,,,,,,, ,,,,,,,,,, command,"set test_data ""Example string for message digest tests.\n""",,,,,,,,, command,"set test_file ""md_data.dat""",,,,,,,,, command,"set test_alt_file ""md_alt_data.dat""",,,,,,,,, command,"set test_key ""Example key""",,,,,,,,, command,::tcltest::makeFile $test_data $test_file,,,,,,,,, ,,,,,,,,,, |
︙ | ︙ | |||
105 106 107 108 109 110 111 | ,,,,,,,,,, command,# MD Error Cases,,,,,,,,, MD Errors,Too few args,,,::tls::md,,,"wrong # args: should be ""::tls::md ?-bin|-hex? ?-cipher name? ?-digest name? ?-key key? ?-mac name? [-channel chan | -command cmdName | -file filename | ?-data? data]""",,,1 MD Errors,Too many args,,,::tls::md too many command line args to pass the test without an error or failing,,,"wrong # args: should be ""::tls::md ?-bin|-hex? ?-cipher name? ?-digest name? ?-key key? ?-mac name? [-channel chan | -command cmdName | -file filename | ?-data? data]""",,,1 MD Errors,Invalid digest,,,::tls::md bogus data,,,"invalid digest ""bogus""",,,1 MD Errors,Invalid digest Arg,,,::tls::md -digest bogus -data data,,,"invalid digest ""bogus""",,,1 MD Errors,No digest,,,::tls::md -hex -data value,,,no digest,,,1 | | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | ,,,,,,,,,, command,# MD Error Cases,,,,,,,,, MD Errors,Too few args,,,::tls::md,,,"wrong # args: should be ""::tls::md ?-bin|-hex? ?-cipher name? ?-digest name? ?-key key? ?-mac name? [-channel chan | -command cmdName | -file filename | ?-data? data]""",,,1 MD Errors,Too many args,,,::tls::md too many command line args to pass the test without an error or failing,,,"wrong # args: should be ""::tls::md ?-bin|-hex? ?-cipher name? ?-digest name? ?-key key? ?-mac name? [-channel chan | -command cmdName | -file filename | ?-data? data]""",,,1 MD Errors,Invalid digest,,,::tls::md bogus data,,,"invalid digest ""bogus""",,,1 MD Errors,Invalid digest Arg,,,::tls::md -digest bogus -data data,,,"invalid digest ""bogus""",,,1 MD Errors,No digest,,,::tls::md -hex -data value,,,no digest,,,1 MD Errors,Invalid option,,,::tls::md -digest sha256 -bogus value,,,"bad option ""-bogus"": must be -bin, -binary, -hex, -hexadecimal, -chan, -channel, -cipher, -command, -data, -digest, -file, -filename, -hash, -key, -length, -mac, or -size",,,1 MD Errors,Invalid file,,,::tls::md -digest sha256 -file bogus,,,"couldn't open ""bogus"": no such file or directory",,,1 MD Errors,Invalid channel,,,::tls::md -digest sha256 -channel bogus,,,"can not find channel named ""bogus""",,,1 MD Errors,No operation,,,::tls::md -digest sha256 -bin,,,"No operation: Use -channel, -command, -data, or -file option",,,1 ,,,,,,,,,, ,,,,,,,,,, command,# Test CMAC command,,,,,,,,, command,"set test_cipher ""aes-128-cbc""",,,,,,,,, |
︙ | ︙ |
Modified tests/digest.test from [141e7b6f90] to [e9e6e071d9].
︙ | ︙ | |||
275 276 277 278 279 280 281 | test MD_Errors-8.5 {No digest} -body { ::tls::md -hex -data value } -result {no digest} -returnCodes {1} test MD_Errors-8.6 {Invalid option} -body { ::tls::md -digest sha256 -bogus value | | | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | test MD_Errors-8.5 {No digest} -body { ::tls::md -hex -data value } -result {no digest} -returnCodes {1} test MD_Errors-8.6 {Invalid option} -body { ::tls::md -digest sha256 -bogus value } -result {bad option "-bogus": must be -bin, -binary, -hex, -hexadecimal, -chan, -channel, -cipher, -command, -data, -digest, -file, -filename, -hash, -key, -length, -mac, or -size} -returnCodes {1} test MD_Errors-8.7 {Invalid file} -body { ::tls::md -digest sha256 -file bogus } -result {couldn't open "bogus": no such file or directory} -returnCodes {1} test MD_Errors-8.8 {Invalid channel} -body { ::tls::md -digest sha256 -channel bogus |
︙ | ︙ |
Modified tests/test_vectors/Hash/SHAKE128.test from [4b0878e01e] to [1d727205ad].
1 2 3 4 5 6 7 8 9 10 11 | # Auto generated from "SHAKE128.txt" lappend auto_path [file dirname [file dirname [file dirname [file dirname [file join [pwd] [info script]]]]]] package require tls package require tcltest tcltest::testConstraint SHAKE128 [expr {[lsearch -nocase [tls::digests] SHAKE128] > -1}] catch {tls::provider legacy} tcltest::test Hash_SHAKE128-1.1 {SHAKE128} \ -constraints SHAKE128 \ -setup {set data ""} \ | | | | | 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 26 27 28 29 | # Auto generated from "SHAKE128.txt" lappend auto_path [file dirname [file dirname [file dirname [file dirname [file join [pwd] [info script]]]]]] package require tls package require tcltest tcltest::testConstraint SHAKE128 [expr {[lsearch -nocase [tls::digests] SHAKE128] > -1}] catch {tls::provider legacy} tcltest::test Hash_SHAKE128-1.1 {SHAKE128} \ -constraints SHAKE128 \ -setup {set data ""} \ -body {tls::digest -digest SHAKE128 -data $data -length 32} \ -match exact -result 7f9c2ba4e88f827d616045507605853ed73b8093f6efbc88eb1a6eacfa66ef26 tcltest::test Hash_SHAKE128-1.2 {SHAKE128} \ -constraints SHAKE128 \ -setup {set data "The quick brown fox jumps over the lazy dog"} \ -body {tls::digest -digest SHAKE128 -data $data -length 32} \ -match exact -result f4202e3c5852f9182a0430fd8144f0a74b95e7417ecae17db0f8cfeed0e3e66e tcltest::test Hash_SHAKE128-1.3 {SHAKE128} \ -constraints SHAKE128 \ -setup {set data [binary decode hex [string repeat a3 200]]} \ -body {tls::digest -digest SHAKE128 -data $data -length 32} \ -match exact -result 131ab8d2b594946b9c81333f9bb6e0ce75c3b93104fa3469d3917457385da037 # Cleanup ::tcltest::cleanupTests return |
Modified tests/test_vectors/Hash/SHAKE128.txt from [0a5deb8560] to [42be99e84a].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # SHAKE128 # From https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values # and FIPS 202 [L = 32] Len = 0 Msg = "" MD = 7f9c2ba4e88f827d616045507605853ed73b8093f6efbc88eb1a6eacfa66ef26 Len = 43 Msg = "The quick brown fox jumps over the lazy dog" MD = f4202e3c5852f9182a0430fd8144f0a74b95e7417ecae17db0f8cfeed0e3e66e Len = 200 Repeat = 200 Msg = a3 MD = 131ab8d2b594946b9c81333f9bb6e0ce75c3b93104fa3469d3917457385da037 | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # SHAKE128 # From https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values # and FIPS 202 [L = 32] Len = 0 Msg = "" MD = 7f9c2ba4e88f827d616045507605853ed73b8093f6efbc88eb1a6eacfa66ef26 Length = 32 Len = 43 Msg = "The quick brown fox jumps over the lazy dog" MD = f4202e3c5852f9182a0430fd8144f0a74b95e7417ecae17db0f8cfeed0e3e66e Length = 32 Len = 200 Repeat = 200 Msg = a3 MD = 131ab8d2b594946b9c81333f9bb6e0ce75c3b93104fa3469d3917457385da037 Length = 32 |
Modified tests/test_vectors/Hash/SHAKE256.test from [2e2114455d] to [211c0f99b9].
1 2 3 4 5 6 7 8 9 10 11 | # Auto generated from "SHAKE256.txt" lappend auto_path [file dirname [file dirname [file dirname [file dirname [file join [pwd] [info script]]]]]] package require tls package require tcltest tcltest::testConstraint SHAKE256 [expr {[lsearch -nocase [tls::digests] SHAKE256] > -1}] catch {tls::provider legacy} tcltest::test Hash_SHAKE256-1.1 {SHAKE256} \ -constraints SHAKE256 \ -setup {set data ""} \ | | | | | 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 26 27 28 29 | # Auto generated from "SHAKE256.txt" lappend auto_path [file dirname [file dirname [file dirname [file dirname [file join [pwd] [info script]]]]]] package require tls package require tcltest tcltest::testConstraint SHAKE256 [expr {[lsearch -nocase [tls::digests] SHAKE256] > -1}] catch {tls::provider legacy} tcltest::test Hash_SHAKE256-1.1 {SHAKE256} \ -constraints SHAKE256 \ -setup {set data ""} \ -body {tls::digest -digest SHAKE256 -data $data -length 64} \ -match exact -result 46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762fd75dc4ddd8c0f200cb05019d67b592f6fc821c49479ab48640292eacb3b7c4be tcltest::test Hash_SHAKE256-1.2 {SHAKE256} \ -constraints SHAKE256 \ -setup {set data "The quick brown fox jumps over the lazy dog"} \ -body {tls::digest -digest SHAKE256 -data $data -length 64} \ -match exact -result 2f671343d9b2e1604dc9dcf0753e5fe15c7c64a0d283cbbf722d411a0e36f6ca1d01d1369a23539cd80f7c054b6e5daf9c962cad5b8ed5bd11998b40d5734442 tcltest::test Hash_SHAKE256-1.3 {SHAKE256} \ -constraints SHAKE256 \ -setup {set data [binary decode hex [string repeat a3 200]]} \ -body {tls::digest -digest SHAKE256 -data $data -length 64} \ -match exact -result cd8a920ed141aa0407a22d59288652e9d9f1a7ee0c1e7c1ca699424da84a904d2d700caae7396ece96604440577da4f3aa22aeb8857f961c4cd8e06f0ae6610b # Cleanup ::tcltest::cleanupTests return |
Modified tests/test_vectors/Hash/SHAKE256.txt from [4480b876cb] to [dc5cbee49c].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # SHAKE256 # From https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values # and FIPS 202 [L = 64] Len = 0 Msg = "" MD = 46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762fd75dc4ddd8c0f200cb05019d67b592f6fc821c49479ab48640292eacb3b7c4be Len = 43 Msg = "The quick brown fox jumps over the lazy dog" MD = 2f671343d9b2e1604dc9dcf0753e5fe15c7c64a0d283cbbf722d411a0e36f6ca1d01d1369a23539cd80f7c054b6e5daf9c962cad5b8ed5bd11998b40d5734442 Len = 200 Repeat = 200 Msg = a3 MD = cd8a920ed141aa0407a22d59288652e9d9f1a7ee0c1e7c1ca699424da84a904d2d700caae7396ece96604440577da4f3aa22aeb8857f961c4cd8e06f0ae6610b | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # SHAKE256 # From https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values # and FIPS 202 [L = 64] Len = 0 Msg = "" MD = 46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762fd75dc4ddd8c0f200cb05019d67b592f6fc821c49479ab48640292eacb3b7c4be Length = 64 Len = 43 Msg = "The quick brown fox jumps over the lazy dog" MD = 2f671343d9b2e1604dc9dcf0753e5fe15c7c64a0d283cbbf722d411a0e36f6ca1d01d1369a23539cd80f7c054b6e5daf9c962cad5b8ed5bd11998b40d5734442 Length = 64 Len = 200 Repeat = 200 Msg = a3 MD = cd8a920ed141aa0407a22d59288652e9d9f1a7ee0c1e7c1ca699424da84a904d2d700caae7396ece96604440577da4f3aa22aeb8857f961c4cd8e06f0ae6610b Length = 64 |
Modified tests/test_vectors/Hash/make_test.tcl from [e263a6e534] to [e069950966].
1 2 3 4 5 6 7 8 | # # Test Vectors # # # Create test case and output to test file # proc do_test {group tail file_num tc digest params} { | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # # 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 Length ""] 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 |
︙ | ︙ | |||
31 32 33 34 35 36 37 38 39 | if {$is_hex} { append line [format {-setup {set data [binary decode hex %s]}} $data] } else { append line [format {-setup {set data %s}} $data] } append line " \\\n\t" # Test body | > > > > > > | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | if {$is_hex} { append line [format {-setup {set data [binary decode hex %s]}} $data] } else { append line [format {-setup {set data %s}} $data] } append line " \\\n\t" if {$config(Length) ne ""} { set opts [format " -length %d" $config(Length)] } else { set opts "" } # Test body append line [format {-body {tls::digest -digest %s -data $data%s}} $digest $opts] append line " \\\n\t" # Test cleanup # Test result set result "" foreach key [list MD Mac Output] { |
︙ | ︙ |