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

Side by Side Diff: third_party/google-endpoints/Crypto/SelfTest/Cipher/test_Blowfish.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/Cipher/test_Blowfish.py: Self-test for the Blowfish cipher
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.Cipher.Blowfish"""
26
27 __revision__ = "$Id$"
28
29 from Crypto.Util.py3compat import *
30
31 # This is a list of (plaintext, ciphertext, key) tuples.
32 test_data = [
33 # Test vectors from http://www.schneier.com/code/vectors.txt
34 ('0000000000000000', '4ef997456198dd78', '0000000000000000'),
35 ('ffffffffffffffff', '51866fd5b85ecb8a', 'ffffffffffffffff'),
36 ('1000000000000001', '7d856f9a613063f2', '3000000000000000'),
37 ('1111111111111111', '2466dd878b963c9d', '1111111111111111'),
38 ('1111111111111111', '61f9c3802281b096', '0123456789abcdef'),
39 ('0123456789abcdef', '7d0cc630afda1ec7', '1111111111111111'),
40 ('0000000000000000', '4ef997456198dd78', '0000000000000000'),
41 ('0123456789abcdef', '0aceab0fc6a0a28d', 'fedcba9876543210'),
42 ('01a1d6d039776742', '59c68245eb05282b', '7ca110454a1a6e57'),
43 ('5cd54ca83def57da', 'b1b8cc0b250f09a0', '0131d9619dc1376e'),
44 ('0248d43806f67172', '1730e5778bea1da4', '07a1133e4a0b2686'),
45 ('51454b582ddf440a', 'a25e7856cf2651eb', '3849674c2602319e'),
46 ('42fd443059577fa2', '353882b109ce8f1a', '04b915ba43feb5b6'),
47 ('059b5e0851cf143a', '48f4d0884c379918', '0113b970fd34f2ce'),
48 ('0756d8e0774761d2', '432193b78951fc98', '0170f175468fb5e6'),
49 ('762514b829bf486a', '13f04154d69d1ae5', '43297fad38e373fe'),
50 ('3bdd119049372802', '2eedda93ffd39c79', '07a7137045da2a16'),
51 ('26955f6835af609a', 'd887e0393c2da6e3', '04689104c2fd3b2f'),
52 ('164d5e404f275232', '5f99d04f5b163969', '37d06bb516cb7546'),
53 ('6b056e18759f5cca', '4a057a3b24d3977b', '1f08260d1ac2465e'),
54 ('004bd6ef09176062', '452031c1e4fada8e', '584023641aba6176'),
55 ('480d39006ee762f2', '7555ae39f59b87bd', '025816164629b007'),
56 ('437540c8698f3cfa', '53c55f9cb49fc019', '49793ebc79b3258f'),
57 ('072d43a077075292', '7a8e7bfa937e89a3', '4fb05e1515ab73a7'),
58 ('02fe55778117f12a', 'cf9c5d7a4986adb5', '49e95d6d4ca229bf'),
59 ('1d9d5c5018f728c2', 'd1abb290658bc778', '018310dc409b26d6'),
60 ('305532286d6f295a', '55cb3774d13ef201', '1c587f1c13924fef'),
61 ('0123456789abcdef', 'fa34ec4847b268b2', '0101010101010101'),
62 ('0123456789abcdef', 'a790795108ea3cae', '1f1f1f1f0e0e0e0e'),
63 ('0123456789abcdef', 'c39e072d9fac631d', 'e0fee0fef1fef1fe'),
64 ('ffffffffffffffff', '014933e0cdaff6e4', '0000000000000000'),
65 ('0000000000000000', 'f21e9a77b71c49bc', 'ffffffffffffffff'),
66 ('0000000000000000', '245946885754369a', '0123456789abcdef'),
67 ('ffffffffffffffff', '6b5c5a9c5d9e0a5a', 'fedcba9876543210'),
68 ('fedcba9876543210', 'f9ad597c49db005e', 'f0'),
69 ('fedcba9876543210', 'e91d21c1d961a6d6', 'f0e1'),
70 ('fedcba9876543210', 'e9c2b70a1bc65cf3', 'f0e1d2'),
71 ('fedcba9876543210', 'be1e639408640f05', 'f0e1d2c3'),
72 ('fedcba9876543210', 'b39e44481bdb1e6e', 'f0e1d2c3b4'),
73 ('fedcba9876543210', '9457aa83b1928c0d', 'f0e1d2c3b4a5'),
74 ('fedcba9876543210', '8bb77032f960629d', 'f0e1d2c3b4a596'),
75 ('fedcba9876543210', 'e87a244e2cc85e82', 'f0e1d2c3b4a59687'),
76 ('fedcba9876543210', '15750e7a4f4ec577', 'f0e1d2c3b4a5968778'),
77 ('fedcba9876543210', '122ba70b3ab64ae0', 'f0e1d2c3b4a596877869'),
78 ('fedcba9876543210', '3a833c9affc537f6', 'f0e1d2c3b4a5968778695a'),
79 ('fedcba9876543210', '9409da87a90f6bf2', 'f0e1d2c3b4a5968778695a4b'),
80 ('fedcba9876543210', '884f80625060b8b4', 'f0e1d2c3b4a5968778695a4b3c'),
81 ('fedcba9876543210', '1f85031c19e11968', 'f0e1d2c3b4a5968778695a4b3c2d'),
82 ('fedcba9876543210', '79d9373a714ca34f', 'f0e1d2c3b4a5968778695a4b3c2d1e'),
83 ('fedcba9876543210', '93142887ee3be15c',
84 'f0e1d2c3b4a5968778695a4b3c2d1e0f'),
85 ('fedcba9876543210', '03429e838ce2d14b',
86 'f0e1d2c3b4a5968778695a4b3c2d1e0f00'),
87 ('fedcba9876543210', 'a4299e27469ff67b',
88 'f0e1d2c3b4a5968778695a4b3c2d1e0f0011'),
89 ('fedcba9876543210', 'afd5aed1c1bc96a8',
90 'f0e1d2c3b4a5968778695a4b3c2d1e0f001122'),
91 ('fedcba9876543210', '10851c0e3858da9f',
92 'f0e1d2c3b4a5968778695a4b3c2d1e0f00112233'),
93 ('fedcba9876543210', 'e6f51ed79b9db21f',
94 'f0e1d2c3b4a5968778695a4b3c2d1e0f0011223344'),
95 ('fedcba9876543210', '64a6e14afd36b46f',
96 'f0e1d2c3b4a5968778695a4b3c2d1e0f001122334455'),
97 ('fedcba9876543210', '80c7d7d45a5479ad',
98 'f0e1d2c3b4a5968778695a4b3c2d1e0f00112233445566'),
99 ('fedcba9876543210', '05044b62fa52d080',
100 'f0e1d2c3b4a5968778695a4b3c2d1e0f0011223344556677'),
101 ]
102
103 def get_tests(config={}):
104 from Crypto.Cipher import Blowfish
105 from common import make_block_tests
106 return make_block_tests(Blowfish, "Blowfish", test_data)
107
108 if __name__ == '__main__':
109 import unittest
110 suite = lambda: unittest.TestSuite(get_tests())
111 unittest.main(defaultTest='suite')
112
113 # vim:set ts=4 sw=4 sts=4 expandtab:
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698