test_pkcs1_oaep.py 文件源码

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

项目:aws-cfn-plex 作者: lordmuffin 项目源码 文件源码
def testEncryptDecrypt1(self):
                # Helper function to monitor what's requested from RNG
                global asked
                def localRng(N):
                    global asked
                    asked += N
                    return self.rng(N)
                # Verify that OAEP is friendly to all hashes
                for hashmod in (MD2,MD5,SHA1,SHA256,RIPEMD):
                    # Verify that encrypt() asks for as many random bytes
                    # as the hash output size
                    asked = 0
                    pt = self.rng(40)
                    self.key1024._randfunc = localRng
                    cipher = PKCS.new(self.key1024, hashmod)
                    ct = cipher.encrypt(pt)
                    self.assertEqual(cipher.decrypt(ct), pt)
                    self.failUnless(asked > hashmod.digest_size)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号