Debian Codegraph @

lib/Crypto/SelfTest/Hash/test_SHA224.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2 #
3 # SelfTest/Hash/test_SHA224.py: Self-test for the SHA-224 hash function
4 #
5 # Written in 2008 by Dwayne C. Litzenberger <[email protected]>
6 #
7 # ===================================================================
8 # The contents of this file are dedicated to the public domain. To
9 # the extent that dedication to the public domain is not available,
10 # everyone is granted a worldwide, perpetual, royalty-free,
11 # non-exclusive license to exercise all rights associated with the
12 # contents of this file for any purpose whatsoever.
13 # No rights are reserved.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 # SOFTWARE.
23 # ===================================================================
24
25 """Self-test suite for Crypto.Hash.SHA224"""
26
27 # Test vectors from various sources
28 # This is a list of (expected_result, input[, description]) tuples.
29 test_data = [
30
31 # RFC 3874: Section 3.1, "Test Vector #1
32 ('23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7', 'abc'),
33
34 # RFC 3874: Section 3.2, "Test Vector #2
35 ('75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525', 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'),
36
37 # RFC 3874: Section 3.3, "Test Vector #3
38 ('20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67', 'a' * 10**6, "'a' * 10**6"),
39
40 # Examples from http://de.wikipedia.org/wiki/Secure_Hash_Algorithm
41 ('d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f', ''),
42
43 ('49b08defa65e644cbf8a2dd9270bdededabc741997d1dadd42026d7b',
44 'Franz jagt im komplett verwahrlosten Taxi quer durch Bayern'),
45
46 ('58911e7fccf2971a7d07f93162d8bd13568e71aa8fc86fc1fe9043d1',
47 'Frank jagt im komplett verwahrlosten Taxi quer durch Bayern'),
48
49 ]
50
51 def get_tests(config={}):
52 from Crypto.Hash import SHA224
53 from .common import make_hash_tests
54 return make_hash_tests(SHA224, "SHA224", test_data,
55 digest_size=28,
56 oid='2.16.840.1.101.3.4.2.4')
57
58 if __name__ == '__main__':
59 import unittest
60 suite = lambda: unittest.TestSuite(get_tests())
61 unittest.main(defaultTest='suite')
62
63 # vim:set ts=4 sw=4 sts=4 expandtab: