key_wrap_utils_test.py 文件源码

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

项目:PACE-python 作者: mit-ll 项目源码 文件源码
def test_invalid_enc_dec(self):
        """ Check that we cannot unwrap a key using a private key that does
            not correspond to the public key used to wrap the key.
        """
        RSA_key = RSA.generate(3072)
        RSA_pk = RSA_key.publickey()
        for i in range(self.num_iters):
            sk = format(random.getrandbits(128), 'b')
            keywrap = wrap_key(sk, RSA_pk)
            other_key = RSA.generate(3072)
            try:
                decrypted_key = unwrap_key(keywrap, other_key)
            except ValueError:
                self.assertTrue(True, 'error')
            else:
                self.assertNotEqual(decrypted_key, sk,
                                    'Decryption succeeded with invalid key')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号