2
# sha256.test: tests for the sha256 commands
4
# This file contains a collection of tests for one or more of the Tcl
5
# built-in commands. Sourcing this file into Tcl runs the tests and
6
# generates output for errors. No output means no errors were found.
8
# RCS: @(#) $Id: sha256.test,v 1.6 2006/10/13 06:23:29 andreas_kupries Exp $
10
# -------------------------------------------------------------------------
13
[file dirname [file dirname [file join [pwd] [info script]]]] \
14
devtools testutilities.tcl]
21
useLocalKeep sha256.tcl sha256 ::sha2
23
useLocal sha256.tcl sha256 ::sha2
28
# -------------------------------------------------------------------------
29
# Now the package specific tests....
30
# -------------------------------------------------------------------------
32
test sha256-1.0 {sha256 usage} {
33
catch {::sha2::sha256} result
35
} "wrong # args: should be \"::sha2::sha256 ?-hex|-bin? -filename file | -channel channel | string\""
37
test sha224-1.0 {sha224 usage} {
38
catch {::sha2::sha224} result
40
} "wrong # args: should be \"::sha2::sha224 ?-hex|-bin? -filename file | -channel channel | string\""
42
# -------------------------------------------------------------------------
45
# FIPS 180-2 test vectors SHA-256
49
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" \
50
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" \
51
"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1" \
52
[string repeat a 1000000] \
53
"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0" ]
55
# FIPS 180-2 test vectors SHA-224
59
"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7" \
60
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" \
61
"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525" \
62
[string repeat a 1000000] \
63
"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67" ]
65
# -------------------------------------------------------------------------
67
TestAccelDo sha2 impl {
69
foreach {msg hash} $vectorsD {
70
test sha256-${impl}-2.$n {FIPS-180-2 test vectors for SHA-256} {
71
list [catch {::sha2::sha256 $msg} r] $r
72
} [list 0 $hash] ; # {}
77
foreach {msg hash} $vectorsDT {
78
test sha224-${impl}-2.$n {FIPS-180-2 test vectors for SHA-224} {
79
list [catch {::sha2::sha224 $msg} r] $r
80
} [list 0 $hash] ; # {}
85
# -------------------------------------------------------------------------
90
# -------------------------------------------------------------------------
93
# indent-tabs-mode: nil