OLD | NEW |
(Empty) | |
| 1 # -*- coding: utf-8 -*- |
| 2 # |
| 3 # SelfTest/Cipher/ARC4.py: Self-test for the Alleged-RC4 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.ARC4""" |
| 26 |
| 27 __revision__ = "$Id$" |
| 28 |
| 29 from Crypto.Util.py3compat import * |
| 30 |
| 31 # This is a list of (plaintext, ciphertext, key[, description]) tuples. |
| 32 test_data = [ |
| 33 # Test vectors from Eric Rescorla's message with the subject |
| 34 # "RC4 compatibility testing", sent to the cipherpunks mailing list on |
| 35 # September 13, 1994. |
| 36 # http://cypherpunks.venona.com/date/1994/09/msg00420.html |
| 37 |
| 38 ('0123456789abcdef', '75b7878099e0c596', '0123456789abcdef', |
| 39 'Test vector 0'), |
| 40 |
| 41 ('0000000000000000', '7494c2e7104b0879', '0123456789abcdef', |
| 42 'Test vector 1'), |
| 43 |
| 44 ('0000000000000000', 'de188941a3375d3a', '0000000000000000', |
| 45 'Test vector 2'), |
| 46 |
| 47 ('00000000000000000000', 'd6a141a7ec3c38dfbd61', 'ef012345', |
| 48 'Test vector 3'), |
| 49 |
| 50 ('01' * 512, |
| 51 '7595c3e6114a09780c4ad452338e1ffd9a1be9498f813d76533449b6778dcad8' |
| 52 + 'c78a8d2ba9ac66085d0e53d59c26c2d1c490c1ebbe0ce66d1b6b1b13b6b919b8' |
| 53 + '47c25a91447a95e75e4ef16779cde8bf0a95850e32af9689444fd377108f98fd' |
| 54 + 'cbd4e726567500990bcc7e0ca3c4aaa304a387d20f3b8fbbcd42a1bd311d7a43' |
| 55 + '03dda5ab078896ae80c18b0af66dff319616eb784e495ad2ce90d7f772a81747' |
| 56 + 'b65f62093b1e0db9e5ba532fafec47508323e671327df9444432cb7367cec82f' |
| 57 + '5d44c0d00b67d650a075cd4b70dedd77eb9b10231b6b5b741347396d62897421' |
| 58 + 'd43df9b42e446e358e9c11a9b2184ecbef0cd8e7a877ef968f1390ec9b3d35a5' |
| 59 + '585cb009290e2fcde7b5ec66d9084be44055a619d9dd7fc3166f9487f7cb2729' |
| 60 + '12426445998514c15d53a18c864ce3a2b7555793988126520eacf2e3066e230c' |
| 61 + '91bee4dd5304f5fd0405b35bd99c73135d3d9bc335ee049ef69b3867bf2d7bd1' |
| 62 + 'eaa595d8bfc0066ff8d31509eb0c6caa006c807a623ef84c3d33c195d23ee320' |
| 63 + 'c40de0558157c822d4b8c569d849aed59d4e0fd7f379586b4b7ff684ed6a189f' |
| 64 + '7486d49b9c4bad9ba24b96abf924372c8a8fffb10d55354900a77a3db5f205e1' |
| 65 + 'b99fcd8660863a159ad4abe40fa48934163ddde542a6585540fd683cbfd8c00f' |
| 66 + '12129a284deacc4cdefe58be7137541c047126c8d49e2755ab181ab7e940b0c0', |
| 67 '0123456789abcdef', |
| 68 "Test vector 4"), |
| 69 ] |
| 70 |
| 71 def get_tests(config={}): |
| 72 from Crypto.Cipher import ARC4 |
| 73 from common import make_stream_tests |
| 74 return make_stream_tests(ARC4, "ARC4", test_data) |
| 75 |
| 76 if __name__ == '__main__': |
| 77 import unittest |
| 78 suite = lambda: unittest.TestSuite(get_tests()) |
| 79 unittest.main(defaultTest='suite') |
| 80 |
| 81 # vim:set ts=4 sw=4 sts=4 expandtab: |
OLD | NEW |