13:65
  "   ˆl–ßi~”Še¶¥8 Y¸Ë÷1hß¿ƒh¹ÃÂ      1
  9   	ˆl–ßi~”Še¶¥8 Y¸\l
bÑ¿Àƒh¹a–ßi~”Še¶¥8 ^¸î¥1hßÄ      	13:69
  #   ˆl–ß=¿J	¥4Ò‚ D Eq¶î21hßÂ„m¶÷¿Å <Æ    # -*- coding: utf-8 -*-
#
#  SelfTest/Cipher/DES3.py: Self-test for the Triple-DES cipher
#
# Written in 2008 by Dwayne C. Litzenberger <dlitz@dlitz.net>
#
# ===================================================================
# The contents of this file are dedicated to the public domain.  To
# the extent that dedication to the public domain is not available,
# everyone is granted a worldwide, perpetual, royalty-free,
# non-exclusive license to exercise all rights associated with the
# contents of this file for any purpose whatsoever.
# No rights are reserved.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# ===================================================================

"""Self-test suite for Crypto.Cipher.DES3"""

__revision__ = "$Id$"

from common import dict     # For compatibility with Python 2.1 and 2.2
from Crypto.Util.py3compat import *
from binascii import hexlify

# This is a list of (plaintext, ciphertext, key, description) tuples.
SP800_20_A1_KEY = '01' * 24
SP800_20_A2_PT = '00' * 8
test_data = [
    # Test vector from Appendix B of NIST SP 800-67
    # "Recommendation for the Triple Data Encryption Algorithm (TDEA) Block
    # Cipher"
    # http://csrc.nist.gov/publications/nistpubs/800-67/SP800-67.pdf
    ('54686520717566636b2062726f776e20666f78206a756d70',
        'a826fd8ce53b855fcce21c8112256fe668d5c05dd9b6b900',
        '0123456789abcdef23456789abcdef01456789abcdef0123',
        'NIST SP800-67 B.1'),

    # Test vectors "The Multi-block Message Test (MMT) for DES and TDES"
    # http://csrc.nist.gov/groups/STM/cavp/documents/des/DESMMT.pdf
    ('326a494cd33fe756', 'b22b8d66de970692',
        '627f460e08104a1043cd265d5840eaf1313edf97df2a8a8c',
        'DESMMT #1', dict(mode='CBC', iv='8e29f75ea77e5475')),

    ('84401f78fe6c10876d8ea23094ea5309', '7b1f7c7e3b1c948ebd04a75ffba7d2f5',
        '37ae5ebf46dff2dc0754b94f31cbb3855e7fd36dc870bfae',
        'DESMMT #2', dict(mode='CBC', iv='3d1de3cc132e3b65')),

    # Test vectors from Appendix A of NIST SP 800-20
    # "Modes of Operation Validation System for the Triple Data Encryption
    # Algorithm (TMOVS): Requirements and Procedures"
    # http://csrc.nist.gov/publications/nistpubs/800-20/800-20.pdf

    # Table A.1 - Variable Plaintext Known Answer Test
    ('8000000000000000', '95f8a5e5dd31d900', SP800_20_A1_KEY,
        'NIST SP800-20 A.1 #0'),
    ('4000000000000000', 'dd7f121ca5015619', SP800_20_A1_KEY,
        'NIST SP800-20 A.1 #1'),
    ('2000000000000000', '2e8653104f3834ea', SP800_20_A1_KEY,
        'NIST SP800-20 A.1 #2'),
    ('1000000000000000', '4bd388ff6cd81d4f', SP800_20_A1_KEY,
        'NIST SP800-20 A.1 #3'),
    ('0800000000000000', '20b9e767b2fb1456', SP800_20_A1_KEY,
        'NIST SP800-20 A.1 #4'),
    ('0400000000000000', '55579380d77138ef', SP800_20_A1_KEY,
        'NIST SP800-20 A.1 #5'),
    ('0200000000000000', '6cc5defaaf04512f', SP800_20_A1_KEY,
        'NIST SP800-20 A.1 #6'),
    ('0100000000000000', '0d9f279ba5d87260', SP800_20_A1_KEY,
        'NIST SP800-20 A.1 #7'),
    ('0080000000000000', 'd9031b0271bd5a0a', SP800_20_A1_KEY,
        'NIST SP800-20 A.1 #8'),
    ('0040000000000000', '424250b37c3dd951', SP800_20_A1_KEY,
        'NIST SP800-20 A.1 #9'),
    ('0020000000000000', 'b8061b7ecd9a21e5', SP800_20_A1_KEY,
        'NIST SP800-20 A.1 #10'),
    ('0010000000000000', 'f15d0f286b65bd28', SP800_20_A1_KEY,
        'NIST SP800-20 A.1 #11'),
    ('0008000000000000', 'add0cc8d6e5deba1', SP800_20_A1_KEY,
 