def get_tests(config={}):
    global test_data
    from Crypto.Hash import HMAC, MD5, SHA as SHA1, SHA256
    from common import make_mac_tests
    hashmods = dict(MD5=MD5, SHA1=SHA1, SHA256=SHA256, default=None)
    try:
        from Crypto.Hash import SHA224, SHA384, SHA512
        hashmods.update(dict(SHA224=SHA224, SHA384=SHA384, SHA512=SHA512))
        test_data += hashlib_test_data
    except ImportError:
        import sys
        sys.stderr.write("SelfTest: warning: not testing HMAC-SHA224/384/512 (not available)\n")
    return make_mac_tests(HMAC, "HMAC", test_data, hashmods)
示例#2
0
def get_tests(config={}):
    global test_data
    from Crypto.Hash import HMAC, MD5, SHA as SHA1, SHA256
    from common import make_mac_tests
    hashmods = dict(MD5=MD5, SHA1=SHA1, SHA256=SHA256, default=None)
    try:
        from Crypto.Hash import SHA224, SHA384, SHA512
        hashmods.update(dict(SHA224=SHA224, SHA384=SHA384, SHA512=SHA512))
        test_data += hashlib_test_data
    except ImportError:
        import sys
        sys.stderr.write("SelfTest: warning: not testing HMAC-SHA224/384/512 (not available)\n")
    return make_mac_tests(HMAC, "HMAC", test_data, hashmods)
示例#3
0
def get_tests(config={}):
    global test_data
    from common import make_mac_tests

    # Add new() parameters to the back of each test vector
    params_test_data = []
    for row in test_data:
        t = list(row)
        t[4] = dict(ciphermod=t[4])
        params_test_data.append(t)

    return make_mac_tests(CMAC, "CMAC", params_test_data)
示例#4
0
def get_tests(config={}):
    global test_data
    from common import make_mac_tests

    # Add new() parameters to the back of each test vector
    params_test_data = []
    for row in test_data:
        t = list(row)
        t[4] = dict(ciphermod=t[4])
        params_test_data.append(t)

    return make_mac_tests(CMAC, "CMAC", params_test_data)
示例#5
0
def get_tests(config={}):
    global test_data
    from common import make_mac_tests

    # A test vector contains multiple results, each one for a
    # different hash algorithm.
    # Here we expand each test vector into multiple ones,
    # and add the relevant parameters that will be passed to new()
    exp_test_data = []
    for row in test_data:
        for modname in row[2].keys():
            t = list(row)
            t[2] = row[2][modname]
            try:
                t.append(dict(digestmod=globals()[modname]))
                exp_test_data.append(t)
            except AttributeError:
                import sys
                sys.stderr.write("SelfTest: warning: not testing HMAC-%s (not available)\n" % modname)

    return make_mac_tests(HMAC, "HMAC", exp_test_data)
示例#6
0
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'),
示例#7
0
文件: test_ARC2.py 项目: 4ZM/pycrypto
# ===================================================================

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

__revision__ = "$Id$"

from common import dict  # For compatibility with Python 2.1 and 2.2

import unittest
from Crypto.Util.py3compat import *

# This is a list of (plaintext, ciphertext, key[, description[, extra_params]]) tuples.
test_data = [
    # Test vectors from RFC 2268
    # 63-bit effective key length
    (b("0000000000000000"), b("ebb773f993278eff"), b("0000000000000000"), "RFC2268-1", dict(effective_keylen=63)),
    # 64-bit effective key length
    (b("ffffffffffffffff"), b("278b27e42e2f0d49"), b("ffffffffffffffff"), "RFC2268-2", dict(effective_keylen=64)),
    (b("1000000000000001"), b("30649edf9be7d2c2"), b("3000000000000000"), "RFC2268-3", dict(effective_keylen=64)),
    (b("0000000000000000"), b("61a8a244adacccf0"), b("88"), "RFC2268-4", dict(effective_keylen=64)),
    (b("0000000000000000"), b("6ccf4308974c267f"), b("88bca90e90875a"), "RFC2268-5", dict(effective_keylen=64)),
    (
        b("0000000000000000"),
        b("1a807d272bbe5db1"),
        b("88bca90e90875a7f0f79c384627bafb2"),
        "RFC2268-6",
        dict(effective_keylen=64),
    ),
    # 128-bit effective key length
    (
        b("0000000000000000"),
示例#8
0
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =======================================================================
#

"""Self-test suite for CryptoPlus.Cipher.ARC2"""

__revision__ = "$Id$"

from common import dict  # For compatibility with Python 2.1 and 2.2

# This is a list of (plaintext, ciphertext, key[, description[, extra_params]]) tuples.
test_data = [
    # Test vectors from RFC 2268
    # 63-bit effective key length
    ("0000000000000000", "ebb773f993278eff", "0000000000000000", "RFC2268-1", dict(effective_keylen=63)),
    # 64-bit effective key length
    ("ffffffffffffffff", "278b27e42e2f0d49", "ffffffffffffffff", "RFC2268-2", dict(effective_keylen=64)),
    ("1000000000000001", "30649edf9be7d2c2", "3000000000000000", "RFC2268-3", dict(effective_keylen=64)),
    ("0000000000000000", "61a8a244adacccf0", "88", "RFC2268-4", dict(effective_keylen=64)),
    ("0000000000000000", "6ccf4308974c267f", "88bca90e90875a", "RFC2268-5", dict(effective_keylen=64)),
    (
        "0000000000000000",
        "1a807d272bbe5db1",
        "88bca90e90875a7f0f79c384627bafb2",
        "RFC2268-6",
        dict(effective_keylen=64),
    ),
    # 128-bit effective key length
    (
        "0000000000000000",
示例#9
0
文件: test_HMAC.py 项目: 4ZM/pycrypto
def get_tests(config={}):
    from Crypto.Hash import HMAC, MD5, SHA as SHA1, SHA256
    from common import make_mac_tests
    hashmods = dict(MD5=MD5, SHA1=SHA1, SHA256=SHA256, default=None)
    return make_mac_tests(HMAC, "HMAC", test_data, hashmods)
示例#10
0
def get_tests(config={}):
    from Crypto.Hash import HMAC, MD5, SHA as SHA1, SHA256
    from common import make_mac_tests
    hashmods = dict(MD5=MD5, SHA1=SHA1, SHA256=SHA256, default=None)
    return make_mac_tests(HMAC, "HMAC", test_data, hashmods)
示例#11
0
# ===================================================================

"""Self-test suite for Crypto.Hash.HMAC"""

__revision__ = "$Id$"

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

# This is a list of (key, data, results, description) tuples.
test_data = [
    ## Test vectors from RFC 2202 ##
    # Test that the default hashmod is MD5
    ('0b' * 16,
        '4869205468657265',
        dict(default='9294727a3638bb1c13f48ef8158bfc9d'),
        'default-is-MD5'),

    # Test case 1 (MD5)
    ('0b' * 16,
        '4869205468657265',
        dict(MD5='9294727a3638bb1c13f48ef8158bfc9d'),
        'RFC 2202 #1-MD5 (HMAC-MD5)'),

    # Test case 1 (SHA1)
    ('0b' * 20,
        '4869205468657265',
        dict(SHA1='b617318655057264e28bc0b6fb378c8ef146be00'),
        'RFC 2202 #1-SHA1 (HMAC-SHA1)'),

    # Test case 2
示例#12
0
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,
示例#13
0
SP800_20_A2_PT = b("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
    (b('54686520717566636b2062726f776e20666f78206a756d70'),
        b('a826fd8ce53b855fcce21c8112256fe668d5c05dd9b6b900'),
        b('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
    (b('326a494cd33fe756'), b('b22b8d66de970692'),
        b('627f460e08104a1043cd265d5840eaf1313edf97df2a8a8c'),
        'DESMMT #1', dict(mode='CBC', iv=b('8e29f75ea77e5475'))),

    (b('84401f78fe6c10876d8ea23094ea5309'), b('7b1f7c7e3b1c948ebd04a75ffba7d2f5'),
        b('37ae5ebf46dff2dc0754b94f31cbb3855e7fd36dc870bfae'),
        'DESMMT #2', dict(mode='CBC', iv=b('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
    (b('8000000000000000'), b('95f8a5e5dd31d900'), SP800_20_A1_KEY,
        'NIST SP800-20 A.1 #0'),
    (b('4000000000000000'), b('dd7f121ca5015619'), SP800_20_A1_KEY,
        'NIST SP800-20 A.1 #1'),
示例#14
0
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'),
示例#15
0
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,
示例#16
0
# 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.Hash.HMAC"""

__revision__ = "$Id: test_HMAC.py 4769 2010-04-09 17:53:50Z toddw $"

from common import dict  # For compatibility with Python 2.1 and 2.2

# This is a list of (key, data, results, description) tuples.
test_data = [
    ## Test vectors from RFC 2202 ##
    # Test that the default hashmod is MD5
    ('0b' * 16, '4869205468657265',
     dict(default='9294727a3638bb1c13f48ef8158bfc9d'), 'default-is-MD5'),

    # Test case 1 (MD5)
    ('0b' * 16, '4869205468657265',
     dict(MD5='9294727a3638bb1c13f48ef8158bfc9d'), 'RFC 2202 #1-MD5 (HMAC-MD5)'
     ),

    # Test case 1 (SHA1)
    ('0b' * 20, '4869205468657265',
     dict(SHA1='b617318655057264e28bc0b6fb378c8ef146be00'),
     'RFC 2202 #1-SHA1 (HMAC-SHA1)'),

    # Test case 2
    ('4a656665', '7768617420646f2079612077616e7420666f72206e6f7468696e673f',
     dict(MD5='750c783e6ab0b503eaa86e310a5db738',
          SHA1='effcdf6ae5eb2fa2d27416d5f184df9c259a7c79'),
示例#17
0
#
"""Self-test suite for Crypto.Cipher.ARC2"""

__revision__ = "$Id$"

from common import dict  # For compatibility with Python 2.1 and 2.2

import unittest

# This is a list of (plaintext, ciphertext, key[, description[, extra_params]]) tuples.
test_data = [
    # Test vectors from RFC 2268

    # 63-bit effective key length
    ('0000000000000000', 'ebb773f993278eff', '0000000000000000', 'RFC2268-1',
     dict(effective_keylen=63)),

    # 64-bit effective key length
    ('ffffffffffffffff', '278b27e42e2f0d49', 'ffffffffffffffff', 'RFC2268-2',
     dict(effective_keylen=64)),
    ('1000000000000001', '30649edf9be7d2c2', '3000000000000000', 'RFC2268-3',
     dict(effective_keylen=64)),
    ('0000000000000000', '61a8a244adacccf0', '88', 'RFC2268-4',
     dict(effective_keylen=64)),
    ('0000000000000000', '6ccf4308974c267f', '88bca90e90875a', 'RFC2268-5',
     dict(effective_keylen=64)),
    ('0000000000000000',
     '1a807d272bbe5db1', '88bca90e90875a7f0f79c384627bafb2', 'RFC2268-6',
     dict(effective_keylen=64)),

    # 128-bit effective key length
# ===================================================================

"""Self-test suite for Crypto.Hash.HMAC"""

__revision__ = "$Id$"

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

# This is a list of (key, data, results, description) tuples.
test_data = [
    ## Test vectors from RFC 2202 ##
    # Test that the default hashmod is MD5
    ('0b' * 16,
        '4869205468657265',
        dict(default='9294727a3638bb1c13f48ef8158bfc9d'),
        'default-is-MD5'),

    # Test case 1 (MD5)
    ('0b' * 16,
        '4869205468657265',
        dict(MD5='9294727a3638bb1c13f48ef8158bfc9d'),
        'RFC 2202 #1-MD5 (HMAC-MD5)'),

    # Test case 1 (SHA1)
    ('0b' * 20,
        '4869205468657265',
        dict(SHA1='b617318655057264e28bc0b6fb378c8ef146be00'),
        'RFC 2202 #1-SHA1 (HMAC-SHA1)'),

    # Test case 2
示例#19
0
#

"""Self-test suite for CryptoPlus.Cipher.RC5"""

__revision__ = "$Id$"

from common import dict     # For compatibility with Python 2.1 and 2.2

# This is a list of (plaintext, ciphertext, key, description or None, extra_params) tuples.
test_data = [
    # Test vectors from http://theory.lcs.mit.edu/~rivest/Rivest-rc5rev.pdf
    # Rivest, R. L. (1994). "The RC5 Encryption Algorithm" (pdf). Proceedings
    # of the Second International Workshop on Fast Software Encryption (FSE)
    # 1994e: 86–96.
    ('0000000000000000', '21a5dbee154b8f6d', '00000000000000000000000000000000',
        "Rivest94-1", dict(word_size=32, rounds=12)),
    ('21a5dbee154b8f6d', 'f7c013ac5b2b8952', '915f4619be41b2516355a50110a9ce91',
        "Rivest94-2", dict(word_size=32, rounds=12)),
    ('f7c013ac5b2b8952', '2f42b3b70369fc92', '783348e75aeb0f2fd7b169bb8dc16787',
        "Rivest94-3", dict(word_size=32, rounds=12)),
    ('2f42b3b70369fc92', '65c178b284d197cc', 'dc49db1375a5584f6485b413b5f12baf',
        "Rivest94-4", dict(word_size=32, rounds=12)),
    ('65c178b284d197cc', 'eb44e415da319824', '5269f149d41ba0152497574d7f153125',
        "Rivest94-5", dict(word_size=32, rounds=12)),

    # Test vectors from RFC 2040
    ('0000000000000000', '7a7bba4d79111d1e', '00', 'RFC2040-1', dict(rounds=0, mode='CBC', iv='0000000000000000')),
    ('ffffffffffffffff', '797bba4d78111d1e', '00', 'RFC2040-2', dict(rounds=0, mode='CBC', iv='0000000000000000')),
    ('0000000000000000', '7a7bba4d79111d1f', '00', 'RFC2040-3', dict(rounds=0, mode='CBC', iv='0000000000000001')),
    ('0000000000000001', '7a7bba4d79111d1f', '00', 'RFC2040-4', dict(rounds=0, mode='CBC', iv='0000000000000000')),
    ('1020304050607080', '8b9ded91ce7794a6', '00', 'RFC2040-5', dict(rounds=0, mode='CBC', iv='0102030405060708')),
示例#20
0
文件: test_HMAC.py 项目: 4ZM/pycrypto
# ===================================================================

"""Self-test suite for Crypto.Hash.HMAC"""

__revision__ = "$Id$"

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

# This is a list of (key, data, results, description) tuples.
test_data = [
    ## Test vectors from RFC 2202 ##
    # Test that the default hashmod is MD5
    (b('0b') * 16,
        b('4869205468657265'),
        dict(default=b('9294727a3638bb1c13f48ef8158bfc9d')),
        'default-is-MD5'),

    # Test case 1 (MD5)
    (b('0b') * 16,
        b('4869205468657265'),
        dict(MD5=b('9294727a3638bb1c13f48ef8158bfc9d')),
        'RFC 2202 #1-MD5 (HMAC-MD5)'),

    # Test case 1 (SHA1)
    (b('0b') * 20,
        b('4869205468657265'),
        dict(SHA1=b('b617318655057264e28bc0b6fb378c8ef146be00')),
        'RFC 2202 #1-SHA1 (HMAC-SHA1)'),

    # Test case 2
示例#21
0
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# =======================================================================
#
"""Self-test suite for CryptoPlus.Cipher.ARC2"""

__revision__ = "$Id$"

from common import dict  # For compatibility with Python 2.1 and 2.2

# This is a list of (plaintext, ciphertext, key[, description[, extra_params]]) tuples.
test_data = [
    # Test vectors from RFC 2268

    # 63-bit effective key length
    ('0000000000000000', 'ebb773f993278eff', '0000000000000000', 'RFC2268-1',
     dict(effective_keylen=63)),

    # 64-bit effective key length
    ('ffffffffffffffff', '278b27e42e2f0d49', 'ffffffffffffffff', 'RFC2268-2',
     dict(effective_keylen=64)),
    ('1000000000000001', '30649edf9be7d2c2', '3000000000000000', 'RFC2268-3',
     dict(effective_keylen=64)),
    ('0000000000000000', '61a8a244adacccf0', '88', 'RFC2268-4',
     dict(effective_keylen=64)),
    ('0000000000000000', '6ccf4308974c267f', '88bca90e90875a', 'RFC2268-5',
     dict(effective_keylen=64)),
    ('0000000000000000',
     '1a807d272bbe5db1', '88bca90e90875a7f0f79c384627bafb2', 'RFC2268-6',
     dict(effective_keylen=64)),

    # 128-bit effective key length
示例#22
0
"""Self-test suite for Crypto.Cipher.ARC2"""

__revision__ = "$Id$"

from common import dict     # For compatibility with Python 2.1 and 2.2

import unittest

# This is a list of (plaintext, ciphertext, key[, description[, extra_params]]) tuples.
test_data = [
    # Test vectors from RFC 2268

    # 63-bit effective key length
    ('0000000000000000', 'ebb773f993278eff', '0000000000000000',
        'RFC2268-1', dict(effective_keylen=63)),

    # 64-bit effective key length
    ('ffffffffffffffff', '278b27e42e2f0d49', 'ffffffffffffffff',
        'RFC2268-2', dict(effective_keylen=64)),
    ('1000000000000001', '30649edf9be7d2c2', '3000000000000000',
        'RFC2268-3', dict(effective_keylen=64)),
    ('0000000000000000', '61a8a244adacccf0', '88',
        'RFC2268-4', dict(effective_keylen=64)),
    ('0000000000000000', '6ccf4308974c267f', '88bca90e90875a',
        'RFC2268-5', dict(effective_keylen=64)),
    ('0000000000000000', '1a807d272bbe5db1', '88bca90e90875a7f0f79c384627bafb2',
        'RFC2268-6', dict(effective_keylen=64)),

    # 128-bit effective key length
    ('0000000000000000', '2269552ab0f85ca6', '88bca90e90875a7f0f79c384627bafb2',
示例#23
0
#
"""Self-test suite for CryptoPlus.Cipher.RC5"""

__revision__ = "$Id$"

from common import dict  # For compatibility with Python 2.1 and 2.2

# This is a list of (plaintext, ciphertext, key, description or None, extra_params) tuples.
test_data = [
    # Test vectors from http://theory.lcs.mit.edu/~rivest/Rivest-rc5rev.pdf
    # Rivest, R. L. (1994). "The RC5 Encryption Algorithm" (pdf). Proceedings
    # of the Second International Workshop on Fast Software Encryption (FSE)
    # 1994e: 86–96.
    (b'0000000000000000', b'21a5dbee154b8f6d',
     b'00000000000000000000000000000000', "Rivest94-1",
     dict(word_size=32, rounds=12)),
    (b'21a5dbee154b8f6d', b'f7c013ac5b2b8952',
     b'915f4619be41b2516355a50110a9ce91', "Rivest94-2",
     dict(word_size=32, rounds=12)),
    (b'f7c013ac5b2b8952', b'2f42b3b70369fc92',
     b'783348e75aeb0f2fd7b169bb8dc16787', "Rivest94-3",
     dict(word_size=32, rounds=12)),
    (b'2f42b3b70369fc92', b'65c178b284d197cc',
     b'dc49db1375a5584f6485b413b5f12baf', "Rivest94-4",
     dict(word_size=32, rounds=12)),
    (b'65c178b284d197cc', b'eb44e415da319824',
     b'5269f149d41ba0152497574d7f153125', "Rivest94-5",
     dict(word_size=32, rounds=12)),

    # Test vectors from RFC 2040
    (b'0000000000000000', b'7a7bba4d79111d1e', b'00', 'RFC2040-1',