test_engine.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:deb-python-kmip 作者: openstack 项目源码 文件源码
def test_decrypt_missing_iv_nonce(self):
        """
        Test that the right error is raised when an IV/nonce is not provided
        for the decryption algorithm.
        """
        engine = crypto.CryptographyEngine()

        args = (
            enums.CryptographicAlgorithm.AES,
            b'\x00\x01\x02\x03\x04\x05\x06\x07'
            b'\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F',
            b'\x0F\x0E\x0D\x0C\x0B\x0A\x09\x08'
            b'\x07\x06\x05\x04\x03\x02\x01\x00'
        )
        kwargs = {
            'cipher_mode': enums.BlockCipherMode.CBC,
            'padding_method': enums.PaddingMethod.PKCS5
        }
        self.assertRaisesRegexp(
            exceptions.InvalidField,
            "IV/nonce is required.",
            engine.decrypt,
            *args,
            **kwargs
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号