OLD | NEW |
(Empty) | |
| 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 <dlitz@dlitz.net> |
| 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 __revision__ = "$Id$" |
| 28 |
| 29 # Test vectors from various sources |
| 30 # This is a list of (expected_result, input[, description]) tuples. |
| 31 test_data = [ |
| 32 |
| 33 # RFC 3874: Section 3.1, "Test Vector #1 |
| 34 ('23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7', 'abc'), |
| 35 |
| 36 # RFC 3874: Section 3.2, "Test Vector #2 |
| 37 ('75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525', 'abcdbcdecdefde
fgefghfghighijhijkijkljklmklmnlmnomnopnopq'), |
| 38 |
| 39 # RFC 3874: Section 3.3, "Test Vector #3 |
| 40 ('20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67', 'a' * 10**6, "'
a' * 10**6"), |
| 41 |
| 42 # Examples from http://de.wikipedia.org/wiki/Secure_Hash_Algorithm |
| 43 ('d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f', ''), |
| 44 |
| 45 ('49b08defa65e644cbf8a2dd9270bdededabc741997d1dadd42026d7b', |
| 46 'Franz jagt im komplett verwahrlosten Taxi quer durch Bayern'), |
| 47 |
| 48 ('58911e7fccf2971a7d07f93162d8bd13568e71aa8fc86fc1fe9043d1', |
| 49 'Frank jagt im komplett verwahrlosten Taxi quer durch Bayern'), |
| 50 |
| 51 ] |
| 52 |
| 53 def get_tests(config={}): |
| 54 from Crypto.Hash import SHA224 |
| 55 from common import make_hash_tests |
| 56 return make_hash_tests(SHA224, "SHA224", test_data, |
| 57 digest_size=28, |
| 58 oid='\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x04') |
| 59 |
| 60 if __name__ == '__main__': |
| 61 import unittest |
| 62 suite = lambda: unittest.TestSuite(get_tests()) |
| 63 unittest.main(defaultTest='suite') |
| 64 |
| 65 # vim:set ts=4 sw=4 sts=4 expandtab: |
OLD | NEW |