~ubuntu-branches/ubuntu/trusty/password-gorilla/trusty

« back to all changes in this revision

Viewing changes to sources/sha1/sha256.test

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Schoenfeld
  • Date: 2011-04-07 14:37:34 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110407143734-2r4ckhxj5ej4e0n6
Tags: 1.5.3.4-1
* New upstream version
* Adapt packaging to new upstreams source layout:
  + Search for files in sources/
  + Install new files (msgs, etc.)
  + Remove configure/make invocations (new upstream source does not have
    that anymore...)
* Add {misc:Depends} to depends
* Bump Standards-Version; no changes needed
* Get rid of patches; not needed anymore
* Add a debian/source/format file to indicate the used source format
* Bugfix in package description: Remove article in front of short description

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- tcl -*-
 
2
# sha256.test:  tests for the sha256 commands
 
3
#
 
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.
 
7
#
 
8
# RCS: @(#) $Id: sha256.test,v 1.6 2006/10/13 06:23:29 andreas_kupries Exp $
 
9
 
 
10
# -------------------------------------------------------------------------
 
11
 
 
12
source [file join \
 
13
        [file dirname [file dirname [file join [pwd] [info script]]]] \
 
14
        devtools testutilities.tcl]
 
15
 
 
16
testsNeedTcl     8.2
 
17
testsNeedTcltest 1.0
 
18
 
 
19
testing {
 
20
    if {[useTcllibC]} {
 
21
        useLocalKeep sha256.tcl sha256 ::sha2
 
22
    } else {
 
23
        useLocal     sha256.tcl sha256 ::sha2
 
24
    }
 
25
    TestAccelInit                      ::sha2
 
26
}
 
27
 
 
28
# -------------------------------------------------------------------------
 
29
# Now the package specific tests....
 
30
# -------------------------------------------------------------------------
 
31
 
 
32
test sha256-1.0 {sha256 usage} {
 
33
    catch {::sha2::sha256} result
 
34
    set result
 
35
} "wrong # args: should be \"::sha2::sha256 ?-hex|-bin? -filename file | -channel channel | string\""
 
36
 
 
37
test sha224-1.0 {sha224 usage} {
 
38
    catch {::sha2::sha224} result
 
39
    set result
 
40
} "wrong # args: should be \"::sha2::sha224 ?-hex|-bin? -filename file | -channel channel | string\""
 
41
 
 
42
# -------------------------------------------------------------------------
 
43
# Digest
 
44
 
 
45
# FIPS 180-2 test vectors SHA-256
 
46
set vectorsD \
 
47
    [list \
 
48
         "abc" \
 
49
         "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" \
 
50
         "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" \
 
51
         "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1" \
 
52
         [string repeat a 1000000] \
 
53
         "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0" ]
 
54
 
 
55
# FIPS 180-2 test vectors SHA-224
 
56
set vectorsDT \
 
57
    [list \
 
58
         "abc" \
 
59
         "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7" \
 
60
         "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" \
 
61
         "75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525" \
 
62
         [string repeat a 1000000] \
 
63
         "20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67" ]
 
64
 
 
65
# -------------------------------------------------------------------------
 
66
 
 
67
TestAccelDo sha2 impl {
 
68
    set n 0
 
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] ; # {}
 
73
        incr n
 
74
    }
 
75
 
 
76
    set n 0
 
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] ; # {}
 
81
        incr n
 
82
    }
 
83
}
 
84
 
 
85
# -------------------------------------------------------------------------
 
86
 
 
87
TestAccelExit sha2
 
88
testsuiteCleanup
 
89
 
 
90
# -------------------------------------------------------------------------
 
91
# Local Variables:
 
92
#   mode: tcl
 
93
#   indent-tabs-mode: nil
 
94
# End: