Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(995)

Side by Side Diff: third_party/google-endpoints/Crypto/SelfTest/Hash/test_SHA.py

Issue 2666783008: Add google-endpoints to third_party/. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # -*- coding: utf-8 -*-
2 #
3 # SelfTest/Hash/SHA.py: Self-test for the SHA-1 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.SHA"""
26
27 __revision__ = "$Id$"
28
29 from Crypto.Util.py3compat import *
30
31 # Test vectors from various sources
32 # This is a list of (expected_result, input[, description]) tuples.
33 test_data = [
34 # FIPS PUB 180-2, A.1 - "One-Block Message"
35 ('a9993e364706816aba3e25717850c26c9cd0d89d', 'abc'),
36
37 # FIPS PUB 180-2, A.2 - "Multi-Block Message"
38 ('84983e441c3bd26ebaae4aa1f95129e5e54670f1',
39 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'),
40
41 # FIPS PUB 180-2, A.3 - "Long Message"
42 # ('34aa973cd4c4daa4f61eeb2bdbad27316534016f',
43 # 'a' * 10**6,
44 # '"a" * 10**6'),
45
46 # RFC 3174: Section 7.3, "TEST4" (multiple of 512 bits)
47 ('dea356a2cddd90c7a7ecedc5ebb563934f460452',
48 '01234567' * 80,
49 '"01234567" * 80'),
50 ]
51
52 def get_tests(config={}):
53 from Crypto.Hash import SHA
54 from common import make_hash_tests
55 return make_hash_tests(SHA, "SHA", test_data,
56 digest_size=20,
57 oid="\x06\x05\x2B\x0E\x03\x02\x1A")
58
59 if __name__ == '__main__':
60 import unittest
61 suite = lambda: unittest.TestSuite(get_tests())
62 unittest.main(defaultTest='suite')
63
64 # vim:set ts=4 sw=4 sts=4 expandtab:
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698