OLD | NEW |
(Empty) | |
| 1 # -*- coding: utf-8 -*- |
| 2 # |
| 3 # SelfTest/Cipher/CAST.py: Self-test for the CAST-128 (CAST5) 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.CAST""" |
| 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 RFC 2144, B.1 |
| 34 ('0123456789abcdef', '238b4fe5847e44b2', |
| 35 '0123456712345678234567893456789a', |
| 36 '128-bit key'), |
| 37 |
| 38 ('0123456789abcdef', 'eb6a711a2c02271b', |
| 39 '01234567123456782345', |
| 40 '80-bit key'), |
| 41 |
| 42 ('0123456789abcdef', '7ac816d16e9b302e', |
| 43 '0123456712', |
| 44 '40-bit key'), |
| 45 ] |
| 46 |
| 47 def get_tests(config={}): |
| 48 from Crypto.Cipher import CAST |
| 49 from common import make_block_tests |
| 50 return make_block_tests(CAST, "CAST", test_data) |
| 51 |
| 52 if __name__ == '__main__': |
| 53 import unittest |
| 54 suite = lambda: unittest.TestSuite(get_tests()) |
| 55 unittest.main(defaultTest='suite') |
| 56 |
| 57 # vim:set ts=4 sw=4 sts=4 expandtab: |
OLD | NEW |