当前位置: 首页>>代码示例>>Python>>正文


Python strxor.strxor_c方法代码示例

本文整理汇总了Python中Crypto.Util.strxor.strxor_c方法的典型用法代码示例。如果您正苦于以下问题:Python strxor.strxor_c方法的具体用法?Python strxor.strxor_c怎么用?Python strxor.strxor_c使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Crypto.Util.strxor的用法示例。


在下文中一共展示了strxor.strxor_c方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_degradation

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def test_degradation(self):
        sub_key1 = bchr(1) * 8
        sub_key2 = bchr(255) * 8

        # K1 == K2
        self.assertRaises(ValueError, DES3.adjust_key_parity,
                          sub_key1 * 2 + sub_key2)

        # K2 == K3
        self.assertRaises(ValueError, DES3.adjust_key_parity,
                          sub_key1 + sub_key2 * 2)

        # K1 == K2 == K3
        self.assertRaises(ValueError, DES3.adjust_key_parity,
                          sub_key1 * 3)

        # K1 == K2 (with different parity)
        self.assertRaises(ValueError, DES3.adjust_key_parity,
                          sub_key1  + strxor_c(sub_key1, 1) + sub_key2) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:21,代码来源:test_DES3.py

示例2: runTest

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def runTest(self):
        sub_key1 = bchr(1) * 8
        sub_key2 = bchr(255) * 8

        # K1 == K2
        self.assertRaises(ValueError, DES3.new,
                          sub_key1 * 2 + sub_key2,
                          DES3.MODE_ECB)

        # K2 == K3
        self.assertRaises(ValueError, DES3.new,
                          sub_key1 + sub_key2 * 2,
                          DES3.MODE_ECB)

        # K1 == K2 == K3
        self.assertRaises(ValueError, DES3.new,
                          sub_key1 *3,
                          DES3.MODE_ECB)

        # K2 == K3 (parity is ignored)
        self.assertRaises(ValueError, DES3.new,
                          sub_key1 + sub_key2 + strxor_c(sub_key2, 0x1),
                          DES3.MODE_ECB) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:25,代码来源:test_DES3.py

示例3: test_verify

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def test_verify(self):
        h = self.BLAKE2.new(digest_bytes=self.max_bytes, key=b"4")
        mac = h.digest()
        h.verify(mac)
        wrong_mac = strxor_c(mac, 255)
        self.assertRaises(ValueError, h.verify, wrong_mac) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:8,代码来源:test_BLAKE2.py

示例4: test_verify

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def test_verify(self):
        h = Poly1305.new(key=self.key, cipher=AES)
        mac = h.digest()
        h.verify(mac)
        wrong_mac = strxor_c(mac, 255)
        self.assertRaises(ValueError, h.verify, wrong_mac) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:8,代码来源:test_Poly1305.py

示例5: runTest

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def runTest(self):
        tag = unhexlify(b"fb447350c4e868c52ac3275cf9d4327e")

        msg = b''
        for msg_len in range(5000 + 1):
            key = tag + strxor_c(tag, 0xFF)
            nonce = tag[::-1]
            if msg_len > 0:
                msg = msg + tobytes(tag[0])
            auth = Poly1305.new(key=key, nonce=nonce, cipher=AES, data=msg)
            tag = auth.digest()

        # Compare against output of original DJB's poly1305aes-20050218
        self.assertEqual("CDFA436DDD629C7DC20E1128530BAED2", auth.hexdigest().upper()) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:16,代码来源:test_Poly1305.py

示例6: test1

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def test1(self):
        term1 = unhexlify(b"ff339a83e5cd4cdf5649")
        result = unhexlify(b"be72dbc2a48c0d9e1708")
        self.assertEqual(strxor_c(term1, 65), result) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:6,代码来源:test_strxor.py

示例7: test3

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def test3(self):
        self.assertEqual(strxor_c(b"", 90), b"") 
开发者ID:vcheckzen,项目名称:FODI,代码行数:4,代码来源:test_strxor.py

示例8: test_wrong_range

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def test_wrong_range(self):
        term1 = unhexlify(b"ff339a83e5cd4cdf5649")
        self.assertRaises(ValueError, strxor_c, term1, -1)
        self.assertRaises(ValueError, strxor_c, term1, 256) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:6,代码来源:test_strxor.py

示例9: test_bytearray

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def test_bytearray(self):
        term1 = unhexlify(b"ff339a83e5cd4cdf5649")
        term1_ba = bytearray(term1)
        result = unhexlify(b"be72dbc2a48c0d9e1708")

        self.assertEqual(strxor_c(term1_ba, 65), result) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:8,代码来源:test_strxor.py

示例10: test_memoryview

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def test_memoryview(self):
        term1 = unhexlify(b"ff339a83e5cd4cdf5649")
        term1_mv = memoryview(term1)
        result = unhexlify(b"be72dbc2a48c0d9e1708")

        self.assertEqual(strxor_c(term1_mv, 65), result) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:8,代码来源:test_strxor.py

示例11: test_output_bytearray

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def test_output_bytearray(self):
        term1 = unhexlify(b"ff339a83e5cd4cdf5649")
        original_term1 = term1[:]
        expected_result = unhexlify(b"be72dbc2a48c0d9e1708")
        output = bytearray(len(term1))

        result = strxor_c(term1, 65, output=output)

        self.assertEqual(result, None)
        self.assertEqual(output, expected_result)
        self.assertEqual(term1, original_term1) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:13,代码来源:test_strxor.py

示例12: test_output_overlapping_bytearray

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def test_output_overlapping_bytearray(self):
        """Verify result can be stored in overlapping memory"""

        term1 = bytearray(unhexlify(b"ff339a83e5cd4cdf5649"))
        expected_xor = unhexlify(b"be72dbc2a48c0d9e1708")
        
        result = strxor_c(term1, 65, output=term1)
        
        self.assertEqual(result, None)
        self.assertEqual(term1, expected_xor) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:12,代码来源:test_strxor.py

示例13: test_output_overlapping_memoryview

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def test_output_overlapping_memoryview(self):
        """Verify result can be stored in overlapping memory"""

        term1 = memoryview(bytearray(unhexlify(b"ff339a83e5cd4cdf5649")))
        expected_xor = unhexlify(b"be72dbc2a48c0d9e1708")
        
        result = strxor_c(term1, 65, output=term1)
        
        self.assertEqual(result, None)
        self.assertEqual(term1, expected_xor) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:12,代码来源:test_strxor.py

示例14: test_output_ro_bytes

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def test_output_ro_bytes(self):
        """Verify result cannot be stored in read-only memory"""
        
        term1 = unhexlify(b"ff339a83e5cd4cdf5649")
        
        self.assertRaises(TypeError, strxor_c, term1, 65, output=term1) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:8,代码来源:test_strxor.py

示例15: test_output_ro_memoryview

# 需要导入模块: from Crypto.Util import strxor [as 别名]
# 或者: from Crypto.Util.strxor import strxor_c [as 别名]
def test_output_ro_memoryview(self):
        """Verify result cannot be stored in read-only memory"""
        
        term1 = memoryview(unhexlify(b"ff339a83e5cd4cdf5649"))
        term2 = unhexlify(b"383d4ba020573314395b")
        
        self.assertRaises(TypeError, strxor_c, term1, 65, output=term1) 
开发者ID:vcheckzen,项目名称:FODI,代码行数:9,代码来源:test_strxor.py


注:本文中的Crypto.Util.strxor.strxor_c方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。